我试图使一个视频启动独自当我打开我的观点,但只是它的声音工作。视图为空白。我使用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];
}
尝试将playVideo呼叫移动到viewWillAppear