我正在加载动态数据,这是一个包含一些描述值和视频URL的字典数组。视频可以为空,单个或多个URL路径。我正在使用mpmovieplayercontroller加载视频,而如果单击“快退”或“前进”按钮进行缓冲,则屏幕将变黑,并且看不到任何控件,因此必须删除后台的应用程序。有没有办法解决这个问题。

NSURL *fileURL = [NSURL URLWithString:location];
self.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlaybackComplete:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:self.moviePlayerController];

self.moviePlayerController.controlStyle = MPMovieControlStyleFullscreen;
self.moviePlayerController.movieSourceType = MPMovieSourceTypeFile;
[self.moviePlayerController prepareToPlay];
[self.moviePlayerController.view setFrame: CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
[self.view addSubview:self.moviePlayerController.view];

最佳答案

也许这段代码可以帮助您尝试使用以下代码:

-(void) moviePlaybackComplete:(NSNotification*) aNotification
{
    MPMoviePlayerController *moviePlayer = [aNotification object];

    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];

    [moviePlayer.view removeFromSuperview];

    [self.presentingViewController dismissViewControllerAnimated:YES completion:NULL];
}


可以帮助您,并尝试根据您的要求进行更改应用

10-08 05:45