2015-12-18 202 views
0

我試圖在全屏模式下播放視頻時,屏幕剛剛啓動,但一些如何我無法播放視頻。我使用下面的代碼播放視頻,但視頻不播放請告訴我我怎麼玩它在全屏模式下。在ios中以全屏模式在屏幕上播放視頻?

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]; 

回答

0
if (movieExists) 
{ 
    NSURL *url = [NSURL fileURLWithPath:moviePath]; 
    player = [[MPMoviePlayerViewController alloc]initWithContentURL:url]; 
    player.moviePlayer.fullscreen = YES; 
    player.moviePlayer.scalingMode = MPMovieScalingModeAspectFill; 
} 
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];