音乐已停止通知

时间:2012-10-11 08:32:53

标签: iphone ios cocoa-touch mpmovieplayercontroller

使用MediaPlayer框架在我的iPhone应用程序中播放视频。我正在使用Mediaplayer框架中提供的通知。但每当我的音频/音乐停止时,我都没有收到任何通知。

所以我想知道在iOS中,是否有任何其他框架可以用来在音乐停止时获得通知。任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

添加此观察者:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackState:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:self.ctl];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.ctl];

选择器将是:

- (void)moviePlayBackState:(NSNotification*)notification {
  //called when music stopped or paused
}

- (void)moviePlayBackDidFinish:(NSNotification*)notification {
  //called when music finished
}