MPMusicPlayerController play user playlist (library playlist)

I am finding it impossible to play a library playlist using the MPMusicPlayerController class. I can play catalog playlists without any issues, but and user library specific playlist or song fails with "failed to prepare for play".

 MPMusicPlayerController.applicationMusicPlayer.setQueue(with: [playlistId])
MPMusicPlayerController.applicationMusicPlayer.play()

The above works so easily for playlists retrieved with: https://api.music.apple.com/v1/catalog/au/playlists.

When trying to play a playlist from https://api.music.apple.com/v1/me/library/playlists it fails.

Any ideas?

Replies

Hello @reinhardholl,

Thank you very much for your feedback.

This way of initiating playback is not recommended.

Whenever possible, you should use the playParams field from Apple Music API, which you can decode directly as MPMusicPlayerPlayParameters (this type conforms to Codable, so you can use it inside of your Codable conforming data structures in Swift. Then, you should make a play parameters based queue descriptor which you can pass to this variant of the setQueue(with:) method.

However, I tried this on my end of things, and I'm encountering issues with both your way of setting the queue and the preferred method I just described. We'll investigate these issues, and try to address them.

Thanks again.

Best regards,

Thanks Joe.

Yeah, I did try that approach and it also did not work. Thanks for checking it out.

As a work around I used let query = MPMediaQuery.playlists() to find the MPMediaPlaylistPropertyPersistentID and this seemed to work.

Not the best solution as I need to check for catalog vs local playlists but it works for now.

Looking forward to the fix. Thanks!

Hi JoeKun,

Any feedback on this one yet? Even with my above mentioned solution we still get cases where the playlists don't play as expected causing a bad experience in our app. Would be great if we can get them to reliably play

Hello @reinhardholl,

I fully understand the importance of this issue, and we take it very seriously.

We are still investigating this. We don't have any update beyond that at this time.

Best regards,

Hello @reinhardholl,

We have made changes in iOS 15 beta 4 to address this specific issue. Would you mind trying this again on the latest beta version of iOS 15?

I hope this helps.

Best regards,