Ios 从数据块播放视频
我从节点服务器接收到大量数据的视频。但视频不能在AVPlayer中播放。这是我的密码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
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中更改了这个,但面临同样的问题