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

Accepted Reply

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,

  • > For example, if you have a MusicKit Song, you could pass song.id.rawValue as the productID parameter to the MPMediaPlaylist's addItem(withProductID: )

    This would be great to explicitly state in the docs - I wasn't clear on this point and was very confused about how to integrate MusicKit and the Media Player API until I stumbled across this comment.

  • @JoeKun Is there a way to make the playlist public either at the time of creation or after it has been created?

  • Hello @ashinthetray,

    Thank you for this question. Please refer to the response I just gave you on the other thread you just created about this same topic.

    Best regards,

Replies

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,

  • > For example, if you have a MusicKit Song, you could pass song.id.rawValue as the productID parameter to the MPMediaPlaylist's addItem(withProductID: )

    This would be great to explicitly state in the docs - I wasn't clear on this point and was very confused about how to integrate MusicKit and the Media Player API until I stumbled across this comment.

  • @JoeKun Is there a way to make the playlist public either at the time of creation or after it has been created?

  • Hello @ashinthetray,

    Thank you for this question. Please refer to the response I just gave you on the other thread you just created about this same topic.

    Best regards,