Register for notifications MPMusicPlayerControllerPlaybackStateDidChangeNotification:
[notificationCenter addObserver:self selector:@selector(handlePlaybackStateChanged:) name:MPMusicPlayerControllerPlaybackStateDidChangeNotification object:self.musicPlayer];
and tell the musicPlayerController file these notifications:
[self.musicPlayerController beginGeneratingPlaybackNotifications]
In handlePlaybackStateChanged:you can check the property playbackStatefor musicPlayerController:
- (void)handlePlaybackStateChanged:(NSNotitication*)notification
{
if (self.musicPlayerController.playbackState == MPMusicPlaybackStateStopped ||
self.musicPlayerController.playbackState == MPMusicPlaybackStateInterrupted ||
self.musicPlayerController.playbackState == MPMusicPlaybackStatePaused) {
}
}
source
share