如何在视频开始播放之前使用活动指示器使用MPMoviePlayerController?

Pra*_*ypa 2 iphone mpmovieplayercontroller uiactivityindicatorview

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

Sim*_*iwi 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];
    }

}
Run Code Online (Sandbox Code Playgroud)

我也发现,从这个链接也可以帮助你:http://www.sdkboy.com/?p = 48