我正在使用MPMusicPlayerController
来玩MPMediaItems
. MPMediaItemCollection
s 播放完毕后如何触发事件MPMediaItem
?
问问题
2895 次
1 回答
6
注册MPMusicPlayerControllerPlaybackStateDidChangeNotification
通知:
[notificationCenter addObserver:self selector:@selector(handlePlaybackStateChanged:) name:MPMusicPlayerControllerPlaybackStateDidChangeNotification object:self.musicPlayer];
并告诉你的 musicPlayerController 生成这些通知:
[self.musicPlayerController beginGeneratingPlaybackNotifications];
handlePlaybackStateChanged:
你可以检查musicPlayerController的属性playbackState
:
- (void)handlePlaybackStateChanged:(NSNotitication*)notification
{
if (self.musicPlayerController.playbackState == MPMusicPlaybackStateStopped ||
self.musicPlayerController.playbackState == MPMusicPlaybackStateInterrupted ||
self.musicPlayerController.playbackState == MPMusicPlaybackStatePaused) {
// do your stuff
}
}
于 2010-10-26T18:59:34.277 回答