Sag*_*ann 9 mpmovieplayercontroller seek nsnotification nsnotificationcenter ios
我正在使用MPMoviePlayerController,如何检测电影实际开始播放的时间 - 而不是当用户摆弄搜索控件时?
从我做的测试中,我总是得到一个"加载状态改变"事件,并且(moviePlayer.loadState == MPMovieLoadStatePlayable)就TRUE在电影开始时和用户拖动搜索控件之后(即使他将它从一端拖到中间 - 不一定是电影的开头) .如何区分电影启动和搜索?
Viv*_*wat 28
MPMoviePlaybackState
Constants describing the current playback state of the movie player.
enum {
MPMoviePlaybackStateStopped,
MPMoviePlaybackStatePlaying,
MPMoviePlaybackStatePaused,
MPMoviePlaybackStateInterrupted,
MPMoviePlaybackStateSeekingForward,
MPMoviePlaybackStateSeekingBackward
};
typedef NSInteger MPMoviePlaybackState;
Run Code Online (Sandbox Code Playgroud)
注册MPMoviePlayerPlaybackStateDidChangeNotification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(MPMoviePlayerPlaybackStateDidChange:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:nil];
Run Code Online (Sandbox Code Playgroud)
签入此函数MPMoviePlaybackState
- (void)MPMoviePlayerPlaybackStateDidChange:(NSNotification *)notification
{
if (player.playbackState == MPMoviePlaybackStatePlaying)
{ //playing
}
if (player.playbackState == MPMoviePlaybackStateStopped)
{ //stopped
}if (player.playbackState == MPMoviePlaybackStatePaused)
{ //paused
}if (player.playbackState == MPMoviePlaybackStateInterrupted)
{ //interrupted
}if (player.playbackState == MPMoviePlaybackStateSeekingForward)
{ //seeking forward
}if (player.playbackState == MPMoviePlaybackStateSeekingBackward)
{ //seeking backward
}
}
Run Code Online (Sandbox Code Playgroud)
删除通知
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11206 次 |
| 最近记录: |