简体   繁体   English

AVPlayerViewController卡在本地视频的第一帧

[英]AVPlayerViewController stuck on first frame of local video

In one of my ViewControllers, I have an AVPlayerViewController . 在我的一个ViewController中,我有一个AVPlayerViewController In my viewDidLoad I have 在我的viewDidLoad

self.videoPlayerController = [AVPlayerViewController new];

Then, I play a video using the following method 然后,我使用以下方法播放视频

- (void)playVideo:(NSURL*)videoURL {
    [self presentViewController:self.videoPlayerController animated:YES completion:^(){
        AVPlayer *player = [[AVPlayer alloc] initWithURL:videoURL];
        [self.videoPlayerController setVideoGravity:AVLayerVideoGravityResizeAspect];
        [self.videoPlayerController setPlayer:player];
        [self.videoPlayerController.player play];
    }];
}

When playing a video for the first time, the AVPlayerViewController appears, but the video is stuck on the first frame, and will not play. 首次播放视频时,会出现AVPlayerViewController ,但视频停留在第一帧,因此无法播放。 No audio plays either. 也没有音频播放。

In iOS 10.0, the seekbar in the on screen controls show that the video is playing (it will progress to the end). 在iOS 10.0中,屏幕控件中的搜索栏显示正在播放视频(它将播放到最后)。 In iOS 10.2 however, the seekbar is stuck at 0:00 as well. 但是,在iOS 10.2中,搜寻栏也停留在0:00。

I am experiencing this problem on iPads with iOS versions 10.0 and 10.2, however, it works in the XCode simulator (both 10.0 and 10.2). 我在iOS版本10.0和10.2的iPad上遇到此问题,但是,它在XCode模拟器(10.0和10.2都适用)中有效。

My problem is similar in nature to this. 我的问题本质上与类似

Also, the video plays correctly if you close the ViewController containing the AVPlayerViewController , reopen it, and attempt to play the video again. 另外,如果关闭包含AVPlayerViewController的ViewController,然后重新打开它,然后尝试再次播放视频,则视频可以正确播放。

I guess that the problem is in your video file. 我想问题出在您的视频文件中。 Try to download another video mp4 video sample . 尝试下载另一个视频mp4视频示例 Add it to your project and try. 将其添加到您的项目中,然后尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM