I am trying to play video in full screen mode when screen is just launched but some how i am not able to play the video.I am using below code to play the video but video is not playing please tell me how can i play it in full screen mode.
我正试图在屏幕刚刚启动时以全屏模式播放视频,但有些我怎么也无法播放视频。我使用下面的代码来播放视频但是视频没有播放请告诉我如何才能播放它全屏模式。
NSURL *fileURL = [NSURL URLWithString:[IMAGE_BASE_URL stringByAppendingString:self.image_url]];
[self.moviePlayerController.view setFrame:CGRectMake(0, 70, self.view.frame.size.width, self.view.frame.size.height)];
self.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
CGRect movieFrame;
movieFrame.size = self.view_video.frame.size;
[self.moviePlayerController.view setFrame:movieFrame];
[self.moviePlayerController setControlStyle:MPMovieControlStyleEmbedded];
[self.moviePlayerController.view setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.moviePlayerController setScalingMode:MPMovieScalingModeFill];
[self.view_video addSubview:self.moviePlayerController.view];
[self.view_video bringSubviewToFront:self.moviePlayerController.view];
[self.moviePlayerController play];
[self.moviePlayerController setFullscreen:TRUE animated:TRUE];
[self.moviePlayerController setScalingMode:MPMovieScalingModeAspectFill];
[self.moviePlayerController setControlStyle:MPMovieControlStyleFullscreen];
2 个解决方案
#1
0
if (movieExists)
{
NSURL *url = [NSURL fileURLWithPath:moviePath];
player = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
player.moviePlayer.fullscreen = YES;
player.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
}
#2
0
self.moviePlayerController = [[MPMoviePlayerController alloc] init];
[self.moviePlayerController.view setFrame:CGRectMake(0, 70,self.view.frame.size.width, self.view.frame.size.height)];
[self.moviePlayerController setShouldAutoplay:NO];
[self.moviePlayerController setContentURL:self.videoURL];
[self.moviePlayerController setFullscreen:YES animated:YES];
self.moviePlayerController.controlStyle=MPMovieControlStyleFullscreen;
[self.moviePlayerController play];
[self.view addSubview:self.videoController.view];
#1
0
if (movieExists)
{
NSURL *url = [NSURL fileURLWithPath:moviePath];
player = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
player.moviePlayer.fullscreen = YES;
player.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
}
#2
0
self.moviePlayerController = [[MPMoviePlayerController alloc] init];
[self.moviePlayerController.view setFrame:CGRectMake(0, 70,self.view.frame.size.width, self.view.frame.size.height)];
[self.moviePlayerController setShouldAutoplay:NO];
[self.moviePlayerController setContentURL:self.videoURL];
[self.moviePlayerController setFullscreen:YES animated:YES];
self.moviePlayerController.controlStyle=MPMovieControlStyleFullscreen;
[self.moviePlayerController play];
[self.view addSubview:self.videoController.view];