Inscrivez-vous MPMusicPlayerControllerPlaybackStateDidChangeNotification
notifications:
[notificationCenter addObserver:self selector:@selector(handlePlaybackStateChanged:) name:MPMusicPlayerControllerPlaybackStateDidChangeNotification object:self.musicPlayer];
et dites à votre musicPlayerController pour générer ces notifications:
[self.musicPlayerController beginGeneratingPlaybackNotifications];
En handlePlaybackStateChanged:
vous pouvez vérifier la propriété playbackState
de musicPlayerController:
- (void)handlePlaybackStateChanged:(NSNotitication*)notification
{
if (self.musicPlayerController.playbackState == MPMusicPlaybackStateStopped ||
self.musicPlayerController.playbackState == MPMusicPlaybackStateInterrupted ||
self.musicPlayerController.playbackState == MPMusicPlaybackStatePaused) {
// do your stuff
}
}