Closed htalat closed 7 years ago
Ah-ha. You didn't specify whether desktop or mobile Safari, so I'll go through both. Chances are you are subject to the laws of Safari on iOS here.
It's most likely that mobile Safari is restricting HTML5 playlist chaining while in background tabs. Mobile browsers have some pretty tight restrictions here, so SM2 uses a singleton-style Audio()
pattern to ensure that only one sound object is active and in use at any time.
On desktop Safari (OS X), it seems like playlist-style playback works OK - for example, the bar UI underneath the turntable animation on the SM2 homepage.
On Safari on iOS (disclaimer: iOS 11 beta), I get no "next track" using the Bar UI on the SM2 homepage, when a song finishes while in a background tab. It's nice that once I return, playback resumes - but, it would be lovely if playback continued while in the background as well. I think iOS has this to be conservative, and prevent unintended run-on of audio/video content.
If you go to YouTube in iOS Safari and try playing a playlist of videos, same thing - one video ends, and the next does not start until you bring that tab back into the foreground.
The stalled
event is HTML5's way of saying that playback has not yet started, or (IIRC) may have stopped loading etc. My memory's a bit fuzzy on the specifics of the event. Regardless, it is one indicator that playback has not started despite a play()
call on mobile in particular.
Chrome is now returning promises at times for audio playback, which can also be a hint for when auto-play is blocked and similar. I intend to get an update out for SM2 to provide hints when that happens.
(Oh wait, maybe iOS 11, but it seems like YouTube pauses inline video when I switch to a different tab.)
oh sorry, I was facing the issue on Safari desktop! yeah the example on the homepage works fine :/
here's an instance of the logs
@scottschiller In what cases are events Ignored? like the last line in the screenshot above
thanks for your help!
@htalat SM2 will "ignore" some events if an event fires after a SM2 object has been unloaded/destroyed, for example, where there is no SM2 sound object instance to handle the event and/or the underlying HTML5 Audio()
instance has been unloaded or destroyed. Earlier releases that didn't handle this would be at risk of throwing a JS error. I log these messages to be safe, though they are a bit noisy and could probably be ignored.
(Vacation, apologies for late reply.)
On Safari,
If I have at least two sounds in the playing queue and am on another tab, the first sound plays perfectly fine and ends, callback is called. However for the second sound, soundmanager logs shows loading error / stalled and does not start. If a go back to the tab, somehow an event is triggered and the sound is able to load and starts playing.
I hope Im making sense here!