3
我使用MPMusicPlayerController
播放MPMediaItems
在MPMediaItemCollection
。當MPMediaItem
完成比賽時,我該如何射門?使用MPMusicPlayerController播放MPMediaItemCollection,如何獲得播放結束時的事件
謝謝! InterDev中
我使用MPMusicPlayerController
播放MPMediaItems
在MPMediaItemCollection
。當MPMediaItem
完成比賽時,我該如何射門?使用MPMusicPlayerController播放MPMediaItemCollection,如何獲得播放結束時的事件
謝謝! InterDev中
註冊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
}
}