Stopping music on app termination

Using an applicationMusicPlayer, how do you ensure music is stopped when the user swipes in task manager up to force quit an app?

Replies

IOS 11 broke this for me. The applicationMusicPlayer music never stops after app termination ala the systemMusicPlayer. I can't find any documentation mentionaing this change.

Same. Seems this is either a bug or a feature but either way it would be nice if somebody at Apple would acknowledge it!

I use systemMusicPlayer, and pausing the musicPlayer doesn't work when the app is terminated.

Probably a feature so other apps don't stop songs already playing in Apple Music. Maybe if the systemMusicPlayer tracked which app the queue was set in, Apple could get this to work.


Does anyone have workarounds for this?



- (void)applicationWillTerminate:(UIApplication *)application {
    ...
    if (musicPlayer.playbackState == MPMusicPlaybackStatePlaying) {
        [musicPlayer pause];
    }
}

>would be nice if somebody


...filed a bug to see what comes back.