Is there any way to get notifications on Apple Music playback in the background?

341 Views Asked by At

I know this issue has been asked numerous times here (*), but years go by and still this is a problem. If anybody has ANY pointers to try, I'll be most thankfull.

The problem is that I want to be notified when, from the lockscreen, the user wants to play, pause, skip a track from Apple Music.

I'm using MPMusicPlayerController to play music from Apple Music (as I understand AVPlayer can't be used); and in particular I'm using the systemMusicPlayer. The thing is that this player is actually the "Apple Music player", ie it's like opening Apple Music and playing music. Moreover, when playing in the background, the lockscreen controls redirect to the Apple Music app.

This causes that my app is not notified when the user does anything. Even though I'm supposedly receiving RemoteControlEvents, I don't get any because it is Apple Music that handles it, and I can't be notified.
It seems I can only be notified on a playback state change or if the now playing item changes, but this informs after the user tapped the button and the action was performed; and I need to be informed in advance as I want the user to be able to play music from multiple services altogether.

I've tried using the applicationMusicPlayer or the applicationQueuePlayer but it seems they do not work in the lockscreen player. They do work in the background as I can control the music from the Command Center, but the lockscreen playback controls don't appear.

(*) Same questions here, here and here to list a few, but all from more than a year ago.

1

There are 1 best solutions below

0
On

Unfortunately not. applicationQueuePlayer would have been the way but as you’ve pointed out there is a bug where it doesn’t show up on the lock screen.