0

I am using this code with autolayout view controller and playing this video in another view called videoView but it is not playing the video in fullscreen.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:saveFileName];
    NSURL *url1 = [[NSURL alloc] initFileURLWithPath: path];
    videoPlayer = [AVPlayer playerWithURL:url1] ;
    self.avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:videoPlayer];


    avPlayerLayer.frame = self.videoView.bounds;
    [self.videoView.layer addSublayer: avPlayerLayer];
    [videoView setHidden:NO];

    [self.videoPlayer play];
iTag
  • 413
  • 1
  • 4
  • 10

1 Answers1

0
Use MPMPMoviePlayerViewController,

    MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:url1];
        NSError *_error = nil;
        [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &_error];
        [self presentMoviePlayerViewControllerAnimated:mpvc];
karthika
  • 4,085
  • 3
  • 21
  • 23