Playing Music Videos from Apple Music API

Hi there!

I have been trying to play the music videos we get from Apple Music API and have been unsuccessful.

Here's my code:

var video: MusicVideo 

var body: some View {
  VideoPlayer(player: AVPlayer(url: video.url!))
}

I know the URL from the MusicVideo is not in a music format but just the URL to the video in the Apple Music catalog.

How do I go about playing it without using something like MPMusicPlayerController.systemMusicPlayer.openToPlay(queueDescriptor) and provide an in-app experience (and not take the user to the Apple Music app)?

Hello @snuff4,

Playing Music Videos with the MusicKit framework is not currently possible.

Please refer to this older thread with more details about a workaround to achieve this with Media Player.

I hope this helps.

Best regards,

Playing Music Videos from Apple Music API
 
 
Q