alinder
alinder

Reputation: 216

Certain operations cause MPMusicPlayerApplicationController to lock up with "Failed to get play queue identifers" errors

I have a music player application that makes use of MPMusicPlayerApplicationController to play songs from Apple Music, which I access using MPMediaQuery. During certain queue operations (skipping ahead, removing items from the queue), it will throw the below error for every remaining song in the queue and stop responding to playback commands. The app must be force quit before playback works again.

2019-11-16 12:53:39.926758-0500 Albums[32354:6195330] [Middleware] RRC : Request failed with error: Error Domain=MPRequestErrorDomain Code=1 "(null)" UserInfo={MPRequestUnderlyingErrorsUserInfoKey=( "Error Domain=MPCPlayerRequestErrorDomain Code=2000 \"Failed to get play queue identifers\" UserInfo={NSDebugDescription=Failed to get play queue identifers, NSUnderlyingError=0x130005ec0 {Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=35 \"(null)\"}}" )}

The issue crops up less often when skipping ahead songs, but it has become frustratingly repeatable after I recently added the ability to remove an upcoming full album from the queue. Here is how I implement that:

  public func removeAlbumFromQueue(album: MPMediaItemCollection, completion: @escaping (Error?) -> Void) {

        mediaPlayer.perform(queueTransaction: { (queue) in

          for song in album.items {

            queue.remove(song)
            }
        }) { (queue, error) in
            if let error = error {
                print(error.localizedDescription)
                completion(error)
            } else {

                self.currentQueue = MPMediaItemCollection(items: queue.items)
                completion(nil)
            }
        }


    }

This operation might fail with the above error on the second or third time, or it may let me remove a dozen or so albums, but eventually it always throws the above error. It doesn't seem to matter how much time passes between each item I remove, whether the player is playing/paused, or whether the Apple Music songs are s

I'd be grateful if anyone has thoughts or pointers. Every Google link is purple and I'm at a loss. Thanks!

Upvotes: 2

Views: 112

Answers (0)

Related Questions