AVPlayerItem is not able to reproduce audio from music folder on Macbook M1

I have an application that as part of it's functionality, reproduce music from the music library using the AVPlayerItem.

it's working fine on iOS but on the Macbook with M1 processor the audio is not loading.

Plist already contains the items:

NSAppleMusicUsageDescription & NSAppTransportSecurity
What error are you getting from AVPlayerItem?
The audio is not loading, even if the player run, the time is always 0
Do you get any interesting values from AVPlayer.status, AVPlayer.error, AVPlayerItem.status, AVPlayerItem.error? Is AVPlayerItemFailedToPlayToEndTimeNotification being posted?
Thanks for the comments, there is in fact an error that i didn't see before :

AVQueuePlayer status: AVPlayerStatusReadyToPlay
AVQueuePlayer error: nil

AVPlayerItem status: AVPlayerItemStatusFailed
AVPlayerItem error: Error Domain=NSCocoaErrorDomain Code=257 "The file couldn’t be opened because you don’t have permission to view it." UserInfo={NSUnderlyingError=0x600002a7f5d0 {Error Domain=NSOSStatusErrorDomain Code=-12203 "(null)"}}

AVURLAsset: <AVURLAsset: 0x600002504980, URL = file:///Users/xx/Music/Music/Media.localized/Music/xx/xx/xx.mp3>

It only happens with audios from Music folder

Something interesting is that the app has permission for "Music & Apple Music" in "Security & Privacy" from "System preferences"

Is something else needed to access music folder ?
I'm having the same trouble. One more clue for the Media Engineer (thanks in advance for your help!):
The "'App Name' would like to access Apple Music, your music and video activity, and your media library" dialog is presented each time the app starts on the Mac M1. In iOS, the Settings app allows access to this authorization (Settings > App Name > Media & Apple Music = ON) which persists the answer after the first run of the app on the device.
I suspect the authorization given when the dialog is presented does not persist on the Mac M1.
Hope this helps with an answer that helps us all.

Also, I'm not able to play an Apple Music track in the MPMusicPlayerController in an app on the Mac M1. And currentPlaybackTime returns a zero even when the music player is playing a local track.
I mention these in case they are all related.
I'm having the same trouble, I only have issues with audios from music folder.

"The file couldn’t be opened because you don’t have permission to view it"

But the app has permission for Apple Music.

Hello @adamyanalunas,

Playing Apple Music content directly with AVPlayer is not supported. Instead, you should be using MediaPlayer's MPMusicPlayerController.

I hope this helps.

Best regards,

AVPlayerItem is not able to reproduce audio from music folder on Macbook M1
 
 
Q