I am using MPMusicPlayerController.systemMusicPlayer and adding an array of storeIDs to the controller's queue using the MPMusicPlayerStoreQueueDescriptor.
The general code layout is:
Set up the controller
let controller = MPMusicPlayerController.systemMusicPlayer
Set up the array of ids, then set up the queue descriptor
let queueDescriptor = MPMusicPlayerStoreQueueDescriptor(storeIDs: ids) // ids is an array of valid storeIDs
queueDescriptor.startItemID = firstID // firstID is a valid storeID that also does exists in the array of ids
Set the queue
controller.setQueue(with: queueDescriptor)
print(queueDescriptor.storeIDs) // the correct expected list of storeIDs
Call prepareToPlay
controller.prepareToPlay { error in
if error != nil {
print("error")
}
controller.play() // the result is the same with or without this play() call
}
Once playback has started, navigating to the Apple Music app shows the now playing queue. If the expected queue was [1, 2, 3, 4, 5...] the queue that made it to Apple's system player will sometimes be the entire tracklist, and sometimes be [1, 2, 3]. I am wondering why the entire tracklist does not always make it to Apple. Please assume all storeIDs being passed are completely valid storeIDs since all tracks do properly play when the entire track list does make it in the queue.
Thank you!