Apple music -MPMusicPlayerController sometime can not play

Help me!!

I'm getting a variety of errors when I call prepareToPlay on the MPMusicPlayerController. Sometimes they happen, sometimes they don't. I'm trying to play songs from the Apple Music service. When I don't get the errors, it plays just fine. I have iOS v15.0.2 on my iPhone Xs and I'm using Xcode 13.2. This is my code:

Xcode Command tool result output:

error is Error Domain=MPMusicPlayerControllerErrorDomain Code=2 "Queue was interrupted by another queue" UserInfo={NSDebugDescription=Queue was interrupted by another queue}

Did you see this thread ? Is it a problem similar to yours ?

https://developer.apple.com/forums/thread/650868

Hello @mryd,

In this code, I do not see you ever doing anything with your instance of MPMusicPlayerStoreQueueDescriptor (i.e. _descriptor).

You are supposed to pass it to MPMusicPlayerController's setQueue(with:) before calling prepareToPlay(completionHandler:).

I hope this helps.

Best regards,

Apple music -MPMusicPlayerController sometime can not play
 
 
Q