我需要使用MPMoviePlayerController在我的UIViewcontroller中播放视频。因此,在播放视频之前,我需要在视频缓冲之前显示活动指标视图。视频开始播放后,我需要删除活动指示器。我无法在视频开始播放后立即了解如何获得通知。对此提出任何建议都会有很大帮助。感谢。
答案 0 :(得分:5)
你可能正在寻找这样的东西:
- (void)viewDidAppear:(BOOL)animated {
NSLog(@"VIEW DID LOAD");
// Register to receive a notification that the movie is now in memory and ready to play
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieLoadStateDidChange:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
}
-(void)movieLoadStateDidChange:(id)sender{
NSLog(@"STATE CHANGED");
if(MPMovieLoadStatePlaythroughOK ) {
NSLog(@"State is Playable OK");
NSLog(@"Enough data has been buffered for playback to continue uninterrupted..");
aiv.hidden = YES;
[aiv stopAnimating];
}
}
我也从这个链接中找到了可能对你有用的信息:http://www.sdkboy.com/?p=48
答案 1 :(得分:1)
if(MPMovie LoadState Playthrough){ - 此检查不正确。这总是正确的。
看看: Can a UIActivityIndicator be displayed over a MPMoviePlayerController in full screen mode?