How to detect musickit player's play state change in background

I'm using musickit on iOS 15 in my APP. I want to detect user change the player's play state when app enters the background.

  • For example when user play next song i need to detect the change to refresh my app's widget

Add a Comment

Replies

Hello @zengxing,

If you're using MusicKit's ApplicationMusicPlayer, you should be able to get updates from the state object, which conforms to ObservableObject.

Following guidance from the documentation for ApplicationMusicPlayer, make sure to include a background audio mode in the Info.plist file for your app.

I hope this helps.

Best regards,

  • Thanks JoeKun,

    If i using ApplicationMusicPlayer as player i can't read the current play queue's Entry when user play the music form apple music.

  • @JoeKun Thanks for that info. I don't see specifics about that background-audio-mode plist entry in that doc, though. I just says to include it, with no details or any link to details.

Add a Comment