Playing (non library) Apple Music content - request fails
Asked Answered
W

1

8

I'm trying to play an album, using the following code…

let predicate = MPMediaPropertyPredicate(value: "1459938538", forProperty: MPMediaItemPropertyAlbumPersistentID)
let iCloudPredicate = MPMediaPropertyPredicate(value: true, forProperty: MPMediaItemPropertyIsCloudItem)
let query = MPMediaQuery.albums()
query.filterPredicates = [predicate, iCloudPredicate]

let mp = MPMusicPlayerController.applicationMusicPlayer
mp.setQueue(with: query)
mp.play()

But it's failing with

[SDKPlayback] -[MPMusicPlayerController prepareToPlay] timeout

[MediaRemote] MRC <MPCPlayerPath: route=<MPAVEndpointRoute: 0x280f1a280 name=iPhone uid=LOCAL> origin=iPhoneID bundleID=com.apple.MediaPlayer.RemotePlayerService playerID=MPMusicPlayerApplicationController>: Undo optimistic state [failed] command=Play error=Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1)" UserInfo={NSDebugDescription=Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=1}

[SDKPlayback] -[MPMusicPlayerController play] completed error: Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0" UserInfo={NSDebugDescription=Failed to send command 0, NSUnderlyingError=0x28344c810 {Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1)" UserInfo={NSDebugDescription=Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=1}}}

• If I remove the predicates, it'll play local albums OK.

• SKCloudServiceController.requestAuthorization is .authorized

• The device has both .musicCatalogPlayback and .addToCloudMusicLibrary capabilities.

1459938538 seems to be a valid id (it's for the latest Madonna album - https://music.apple.com/gb/album/madame-x-deluxe/1459938538)

Any hints as to how to play an album that's not in my library?

Whooper answered 20/6, 2019 at 15:23 Comment(2)
Did anyone find an answer to this? I am also facing a similar problem. Could it potentially be a problem on Apple's end?Missi
has anyone found an anwser to this???Chivalry
E
3

MPMediaQuery is only for Library items. You would need to use the web Apple Music search API to get store IDs to use in setting the queue.

Emir answered 30/9, 2019 at 22:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.