视频不在应用程序中播放

Video does not play in app

我有一个应用程序,当用户选择一个按钮时,它会显示一个视频。该代码似乎在视频播放器加载时起作用。我还修改了 NSAppTransportSecurity 设置以包括 NSAllowsArbitraryLoads。我对几个视频进行了硬编码,以查看我的特定视频是否存在问题,但 none 可以正常工作。这是代码,非常感谢任何帮助。

    @IBAction func playVideo(_ sender: Any) {
    func prepare(for segue: UIStoryboardSegue, sender: Any?) {

        let destination = segue.destination as! AVPlayerViewController
        let url = URL(string:
            "http://www.ebookfrenzy.com/ios_book/movie/movie.mov")

        if let movieURL = url {
            destination.player = AVPlayer(url: movieURL)
        }
        let player = AVPlayer(url: url!)
        let playerController = AVPlayerViewController()

        playerController.player = player
        self.addChildViewController(playerController)
        self.view.addSubview(playerController.view)
        playerController.view.frame = self.view.frame

        player.play()
    }

基本上这很好用,

func playVideo() {

    let url = URL(string: "http://www.ebookfrenzy.com/ios_book/movie/movie.mov")
    let player = AVPlayer(url: url!)
    let playerController = AVPlayerViewController()

    playerController.player = player
    self.addChildViewController(playerController)
    self.view.addSubview(playerController.view)
    playerController.view.frame = self.view.frame

    player.play()

}