Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从数据块播放视频_Ios_Swift_Avplayer - Fatal编程技术网

Ios 从数据块播放视频

Ios 从数据块播放视频,ios,swift,avplayer,Ios,Swift,Avplayer,我从节点服务器接收到大量数据的视频。但视频不能在AVPlayer中播放。这是我的密码 let videoUrl = http://staging.teemo.me/api/video/stream/sample12.MOV playVideo(path:videoUrl, self) func playVideo(path:String, controller:UIViewController){ let yourFinal

我从节点服务器接收到大量数据的视频。但视频不能在AVPlayer中播放。这是我的密码

           let videoUrl = http://staging.teemo.me/api/video/stream/sample12.MOV

 playVideo(path:videoUrl, self)

      func playVideo(path:String, controller:UIViewController){
                let yourFinalVideoURL = path
                try! AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, with: [])
                if (yourFinalVideoURL != "") {
                    let player = AVPlayer(url: NSURL(fileURLWithPath: yourFinalVideoURL) as URL)
                    let playerController = AVPlayerViewController()
                    playerController.player = player
                    controller.present(playerController, animated: true) {
                        //player.play()
                        if #available(iOS 10.0, *) {
                            player.playImmediately(atRate: 1.0)
                        } else {
                            player.play()
                        }
                    }
                }
              }

以下代码适用于我:

let videoURL = URL(string: "Some url")
let player = AVPlayer(url: videoURL!)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
self.present(playerViewController, animated: true) {
    playerViewController.player!.play()
}
然而,当我试图使用你的网址,它不工作。 我在.plist中添加了NSAppTransportSecurity,但它也不起作用。
很明显,您的url有问题,请尝试将文件sample12.MOV的扩展名更改为sample12.mp4

您的url字符串不安全。所以我建议你检查一下,我在.mp4中更改了这个,但面临同样的问题