当我打开视图时,我试图让视频单独启动,但只是它的声音有效。视图为空白。我正在使用MPMoviePlayerController执行此操作。
我的代码是:
@property (nonatomic, strong) MPMoviePlayerController *moviePlayer;
- (void)viewDidLoad {
[super viewDidLoad];
[self playVideo];
}
-(void)playVideo {
NSString *videoFile = [[NSBundle mainBundle] pathForResource:@"fds" ofType:@"mp4"];
self.moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL fileURLWithPath:videoFile]];
[self.playerView addSubview:self.moviePlayer.view];
self.moviePlayer.fullscreen = YES;
self.moviePlayer.allowsAirPlay = YES;
[self.moviePlayer play];
}
答案 0 :(得分:0)
尝试将playVideo调用移至viewWillAppear