2010-10-26 1 views

ответ

5

Регистрация для MPMusicPlayerControllerPlaybackStateDidChangeNotification уведомлений:

[notificationCenter addObserver:self selector:@selector(handlePlaybackStateChanged:) name:MPMusicPlayerControllerPlaybackStateDidChangeNotification object:self.musicPlayer]; 

и скажите вашему musicPlayerController для создания этих уведомлений:

[self.musicPlayerController beginGeneratingPlaybackNotifications]; 

В handlePlaybackStateChanged: вы можете проверить playbackState свойство musicPlayerController:

- (void)handlePlaybackStateChanged:(NSNotitication*)notification 
{ 
    if (self.musicPlayerController.playbackState == MPMusicPlaybackStateStopped || 
     self.musicPlayerController.playbackState == MPMusicPlaybackStateInterrupted || 
     self.musicPlayerController.playbackState == MPMusicPlaybackStatePaused) { 
     // do your stuff 
    } 
}