0

我将此代码与自动布局视图控制器一起使用,并在另一个名为 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];
4

1 回答 1

0
Use MPMPMoviePlayerViewController,

    MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:url1];
        NSError *_error = nil;
        [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &_error];
        [self presentMoviePlayerViewControllerAnimated:mpvc];
于 2013-07-23T10:27:19.743 回答