在演示文稿正在进行时尝试显示MPMoviePlayerViewController

时间:2016-03-11 12:30:51

标签: ios mpmovieplayercontroller viewdidlayoutsubviews

我在标题中描述了警告,但我发现这是多次调用viewDidLayoutSubviews的结果。

- (void) viewDidLayoutSubviews
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"wq" ofType:@"mp4"]];
self.playerController = [[MPMoviePlayerViewController alloc]initWithContentURL:url];

[self presentMoviePlayerViewControllerAnimated:self.playerController];
[self.playerController.moviePlayer prepareToPlay];

self.playerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
self.playerController.moviePlayer.controlStyle = MPMovieControlStyleNone;
self.playerController.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
self.playerController.moviePlayer.repeatMode = MPMovieRepeatModeOne;

[self.playerController.view setFrame:self.movieView.bounds];
[self.movieView addSubview:self.playerController.view];

[self.playerController.moviePlayer play];
}

我也试过在(void) loadView中使用上面的代码,但结果是一样的。 我在故事板中也有一些按钮,我不想错过它们。 任何人都可以帮我只有一个MPMoviePlayerViewController吗?

提前致谢!

0 个答案:

没有答案