我需要在一层UIView上播放MPMoviePlayerController。但只有声音出来,没有视频。
theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[theMovie prepareToPlay];
theMovie.view.frame = CGRectMake(0, 0, 200, 150);
[theMovie setControlStyle:MPMovieControlStyleDefault];
[theMovie setFullscreen:NO animated:YES];
theMovie.shouldAutoplay = YES;
[theMovie setContentURL:movieURL];
[self addSubview:theMovie.view];
[theMovie play];
我只有黑屏,只有音频。这是因为我将UIView称为层而不是子视图?因为我的要求是将UIView称为图层。
答案 0 :(得分:0)
看起来不错,请尝试添加:
[_openingMovie setMovieSourceType:MPMovieSourceTypeStreaming];
希望这有帮助
修改强>
在设置SourceType之后尝试设置ContentURL,如下所示
moviePlayerController_ = [[MPMoviePlayerViewController alloc] init];
moviePlayerController_.movieSourceType = MPMovieSourceTypeStreaming;
[moviePlayerController_.moviePlayer setContentURL:url];
此代码快照来自: An AVPlayerItem cannot be associated with more than one instance of AVPlayer'