横向模式iPhone中的视频视图不是全屏

时间:2013-07-23 10:10:05

标签: objective-c uiview avplayer avplayerlayer

我在autolayout视图控制器中使用此代码,并在另一个名为videoView的视图中播放此视频,但它不是全屏播放视频。

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

1 个答案:

答案 0 :(得分:0)

Use MPMPMoviePlayerViewController,

    MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:url1];
        NSError *_error = nil;
        [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &_error];
        [self presentMoviePlayerViewControllerAnimated:mpvc];