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.