Can MusicKit JS play queue continuously when phone is locked

Though I can get MusicKit JS to play continuously on desktop in the background, the player seems to stop at the end of a track on iPhone even if there are more tracks in the queue.

Is this a known limitation? If so, are there any events I can listen to so that the app knows MusicKit has paused playback?

If there is a solution I would appreciate any documentation or examples.

Thank you for the question, @tmccleary

MusicKit JS is unable to play continuously on iOS in the background.

The technical limitation here is that we rely on the MediaElement in iOS for playback, which allows defining a single media asset as the source. The queue is managed in the main JavaScript thread, which is not active while the browser is backgrounded, including when the phone is locked. So when the current track ends, the queue management logic cannot run until the JavaScript thread is active again, which happens when the browser returns to the foreground.

The JavaScript thread would not be able to respond to an event when the browser is backgrounded, but the Page Visibility API’s visibilitychange event should fire when the browser is coming into or leaving the foreground.

Can MusicKit JS play queue continuously when phone is locked
 
 
Q