我需要使用MPMoviePlayerController在UIViewcontroller中播放视频。因此,在播放视频之前,我需要在缓冲视频之前显示活动指示器视图。视频开始播放后,我需要删除活动指示器。视频开始播放后,我无法得知如何获得通知。关于此的任何建议都会有很大帮助。谢谢。

最佳答案

您可能正在寻找这样的东西:

- (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

关于iphone - 在视频开始使用MPMoviePlayerController播放之前如何使用事件指示器?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10999019/

10-12 14:30
查看更多