全屏后MPMoviePlayerController无法正常工作

时间:2014-12-24 11:31:42

标签: ios objective-c mpmovieplayercontroller

我像这样嵌入了MPMoviePlayerController:

[_mediaPlayerView addSubview:moviePlayer.view]; 
[self addChildViewController:moviePlayer];

视频播放正常。当我点击全屏按钮播放器最大化,但我只看到控制按钮,屏幕是空白。装载指示器在旋转。当我取消最大化时,嵌入式视频控制器也是空白的。

1 个答案:

答案 0 :(得分:0)

嵌入MPMoviePlayerController的正确方法:

        self.mediaPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
        [self.mediaPlayer setMovieSourceType:MPMovieSourceTypeFile];
        [self.mediaPlayer setControlStyle:MPMovieControlStyleEmbedded];
        [self.mediaPlayer setShouldAutoplay:NO];
        [self.mediaPlayer prepareToPlay];

        [self.mediaPlayer.view setFrame:self.mediaPlayerView.bounds];
        [self.mediaPlayerView addSubview:self.mediaPlayer.view];
        self.mediaPlayerView.userInteractionEnabled = YES;