Can't read MPMediaItem on iOS App running with Catalyst

Hello,

We've an iOS application that can be launched on macOS (with the "designed for iPhone" available with Catalyst).

This application request authorization on MPMediaLibrary and play MPMediaItem with an audio player. After accepted, the authorization status is well flagged as .authorized

I can browse all MPMediaItem without issue and display them in my app.

But, when it comes the time to convert the MPMediaItem file's URL in AVAudioFile with:

AVAudioFile(forReading: fileURL)

We got 2 warnings in the console:

ExtAudioFile.cpp:211   about to throw -54: open audio file

AVAEInternal.h:109   [AVAudioFile.mm:135:AVAudioFileImpl: (ExtAudioFileOpenURL((CFURLRef)fileURL, &_extAudioFile)): error -54

We finally get an exception with this error:

Error Domain=com.apple.coreaudio.avfaudio Code=-54 "(null)" UserInfo={failed call=ExtAudioFileOpenURL((CFURLRef)fileURL, &_extAudioFile)}

This working perfectly on iOS and iPadOS, but with Catalyst we always got this error whatever the audio (from iTunes library) we try to play.

Why do we have this permission issue only on macOS ? There is something different to do to get permission on macOS ?

thanks !

Can't read MPMediaItem on iOS App running with Catalyst
 
 
Q