Sometimes the MPMusicPlayerController is not playing the music when I start my app. I'm getting following errors (or very similar):
[SDKPlayback] -[MPMusicPlayerController prepareToPlay] completed error: Error Domain=MPCPlayerRequestErrorDomain Code=1 "No commands provided." UserInfo={NSDebugDescription=No commands provided.}
[SDKPlayback] -[MPMusicPlayerController prepareToPlayWithCompletionHandler:] completed error: Error Domain=MPCPlayerRequestErrorDomain Code=1 "No commands provided." UserInfo={NSDebugDescription=No commands provided.}
[MediaRemote] MRC <MPCPlayerPath: route=<MPAVEndpointRoute: 0x281e90540 name=iPhone uid=LOCAL> origin=Nastasia's iPhone-1280262988 bundleID=com.apple.MediaPlayer.RemotePlayerService playerID=MPMusicPlayerApplicationController>: Undo optimistic state [failed] command=Play error=Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRSendCommandError = 4)" UserInfo={NSDebugDescription=Failed to send command 0 (MRSendCommandError = 4)}
[SDKPlayback] -[MPMusicPlayerController play] completed error: Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0" UserInfo={NSDebugDescription=Failed to send command 0, NSUnderlyingError=0x28256b840 {Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRSendCommandError = 4)" UserInfo={NSDebugDescription=Failed to send command 0 (MRSendCommandError = 4)}}}
I'm trying to play songs from Apple Music using the user's paid subscription, so I'm setting the queue with store IDs.
One thing that almost always fixes the situation is opening the iOS Music app, playing something there and coming back to my app.
Here are some extra conditions to consider:
- I'm still in development mode so all that happens during deploying the app to my device in debug mode
- This happens often after I kill the app from Xcode to make some changes in code and then run the app again
- I have relatively old iPhone 6s with iOS 12.4.
Given all those conditions, I still see a lot of people having similar problems and no workaround till now.
If anyone ever experienced this - please let me know how to fix it or if there is a workaround to this.