-
Notifications
You must be signed in to change notification settings - Fork 145
loadState
shixuemei edited this page Sep 22, 2016
·
4 revisions
说明视频当前加载状态,如加载中,加载完成等
typedef NS_OPTIONS(NSUInteger, MPMovieLoadState) {
MPMovieLoadStateUnknown = 0,
MPMovieLoadStatePlayable = 1 << 0,
MPMovieLoadStatePlaythroughOK = 1 << 1,
MPMovieLoadStateStalled = 1 << 2,
};
- MPMovieLoadStateUnknown - 加载情况未知
- MPMovieLoadStatePlayable - 加载完成,可以播放
- MPMovieLoadStatePlaythroughOK - 加载完成,如果shouldAutoPlay为YES,将自动开始播放
- MPMovieLoadStateStalled - 加载中
- 通过loadState属性(只读)获取当前加载状态
- 当接收到MPMoviePlayerLoadStateDidChangeNotification通知时应调用loadState获取一下当前播放器的加载状态;
if (MPMoviePlayerLoadStateDidChangeNotification == notify.name) {
NSLog(@"player load state: %ld", (long)_player.loadState);
if (MPMovieLoadStateStalled & _player.loadState) {
stat.text = [NSString stringWithFormat:@"player start caching"];
NSLog(@"player start caching");
}
if (_player.bufferEmptyCount &&
(MPMovieLoadStatePlayable & _player.loadState ||
MPMovieLoadStatePlaythroughOK & _player.loadState)){
NSLog(@"player finish caching");
NSString *message = [[NSString alloc]initWithFormat:@"loading occurs, %d - %0.3fs",
(int)_player.bufferEmptyCount,
_player.bufferEmptyDuration];
[self toast:message];
}
}

