AVPlayer 启动,但视频暂停稍有延迟

AVPlayer starts, but video pauses for slight delay

我已阅读有关 AVPlayer 启动延迟的信息,但不完全是我的情况,我还没有找到解决方案。

我在应用程序中本地存储了一些 mp4 视频,我正在使用 AVPlayer 播放它。问题是当视频剪辑开始播放时,播放器打开并且您看到视频开始播放,但之前它冻结了不到一秒钟,然后才开始播放。这种延迟使我不安。有什么可以做的吗

我尝试在视频中寻找稍后的时间,但它没有改变任何东西

这是一些代码,如果需要可以提供更多。

谢谢

这是我在 viewDidLoad 中做的

    let videoString:String? = Bundle.main.path(forResource: "cat2", ofType: ".mp4")


    if let url = videoString{

        let videoURL = NSURL(fileURLWithPath: url)

        self.player = AVPlayer(url: videoURL as URL)


        self.playerController.player = self.player



    }

然后在按钮上点击我调用:

 func imageTapped(tapGestureRecognizer: UITapGestureRecognizer)
    {



    let tappedImage = tapGestureRecognizer.view as! UIImageView



    // Your action

    self.present(self.playerController, animated: true, completion: {

        print("Pic tapped")

        self.playerController.player?.play()



    })
}

放:

self.playerController.player?.play()

之前:

 self.present(self.playerController, animated: true, completion: {