MPMusicPlayerController
で再生するためにMPMediaItems
を使用していMPMediaItemCollection
ます。MPMediaItem
の再生が終了したときにイベントを発生させるにはどうすればよいですか?
2895 次
1 に答える
6
MPMusicPlayerControllerPlaybackStateDidChangeNotification
通知登録:
[notificationCenter addObserver:self selector:@selector(handlePlaybackStateChanged:) name:MPMusicPlayerControllerPlaybackStateDidChangeNotification object:self.musicPlayer];
これらの通知を生成するように musicPlayerController に指示します。
[self.musicPlayerController beginGeneratingPlaybackNotifications];
musicPlayerControllerのプロパティをhandlePlaybackStateChanged:
確認できます。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 に答える