I want to pause my application when the user stops the music on the headphones.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playbackStateDidChange:)
name:MPMusicPlayerControllerPlaybackStateDidChangeNotification
object:[MPMusicPlayerController iPodMusicPlayer]];
works good. However, this also works with an incoming phone call.
I added
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(appLostFocus:)
name:UIApplicationWillResignActiveNotification
object:[UIApplication sharedApplication]];
Unfortunately, this is triggered after a pause is detected.
Any ideas?
source
share