How can add songs to a playlist or create a new playlist from my APP?

Hi, I would like to be able to create a playlist from my app or add songs to an existing selected playlist in the user music library, How can I do that ? Is there an API in MusicKit to do that?

The Shazam app is doing something similar with the My Shazam Songs playlist...

Thanks

Answered by in 678682022

Hello @aleroot,

In iOS 15 and aligned releases for other Apple platforms, MusicKit is focused on giving access to the Apple Music catalog.

For this reason, the easiest way to create a playlist and add songs to it is probably to use existing APIs in the MediaPlayer framework.

Specifically, you could use:

Furthermore, you can definitely use the new MusicKit framework alongside MediaPlayer framework. For example, if you have a MusicKit Song, you could pass song.id.rawValue as the productID parameter to the MPMediaPlaylist's addItem(withProductID: ).

I hope this helps.

Best regards,

Accepted Answer

Hello @aleroot,

In iOS 15 and aligned releases for other Apple platforms, MusicKit is focused on giving access to the Apple Music catalog.

For this reason, the easiest way to create a playlist and add songs to it is probably to use existing APIs in the MediaPlayer framework.

Specifically, you could use:

Furthermore, you can definitely use the new MusicKit framework alongside MediaPlayer framework. For example, if you have a MusicKit Song, you could pass song.id.rawValue as the productID parameter to the MPMediaPlaylist's addItem(withProductID: ).

I hope this helps.

Best regards,

How can add songs to a playlist or create a new playlist from my APP?
 
 
Q