Closed nzoschke closed 5 days ago
https://developer.spotify.com/documentation/web-playback-sdk/reference#spotifyplayeractivateelement
Some browsers prevent autoplay of media by ensuring that all playback is triggered by synchronous event-paths originating from user interaction such as a click. In the autoplay disabled browser, to be able to keep the playing state during transfer from other applications to yours, this function needs to be called in advance. Otherwise it will be in pause state once it’s transferred.
Safari does prevent autoplay and is seemingly more aggro about it for security or power savings compared to Chrome.
It seems like the reference docs are wrong. You need to call activateElement
in the synchronous event-path from a click, not before.
Interesting that in Svelte it didn't work in the playPause
helper, but did work in its own effect.
On both Safari desktop and iOS playback doesn't work.
Possibly something different about Safari rules for starting playback:
Autoplay is not allowed by the browser autoplay rules
A click handler needs to correlate with the play interaction