当前位置:  开发笔记 > IOS > 正文

iOS AVPlayer未加载大多数HLS流

如何解决《iOSAVPlayer未加载大多数HLS流》经验,为你挑选了0个好方法。

我正在尝试使用嵌入在AVPlayerViewController中的AVPlayer来传输HLS视频.要做到这一点,我正在做以下设置AVPlayerViewController,遵循苹果文档:https://developer.apple.com/library/mac/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback.html

let url = NSURL.init(string: "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8") // example URL from apple dev works!

let asset = AVURLAsset.init(URL: url!)
let requestedKeys = ["tracks"]
asset.loadValuesAsynchronouslyForKeys(requestedKeys) {
    () -> Void in
    dispatch_async(dispatch_get_main_queue())
        {
            let error = NSErrorPointer()
            let status = asset.statusOfValueForKey("tracks", error: error)

            if (status == AVKeyValueStatus.Loaded) {
                let playerItem = AVPlayerItem.init(asset: asset)
                playerItem.addObserver(self, forKeyPath: "status", options: NSKeyValueObservingOptions.init(rawValue: 0), context: nil)
                self.avPlayerViewController.player = AVPlayer.init(playerItem: playerItem)
            }
            else {
                // You should deal with the error appropriately.
                NSLog("The asset's tracks were not loaded:\n%@", (error.memory)!.localizedDescription);
            }
        }
    }

一切正常.但是当我改变网址时

let url = NSURL.init(string: "http://cdn-fms.rbs.com.br/hls-vod/sample1_1500kbps.f4v.m3u8") // but this one doesn't

或任何其他HLS流它不再起作用.我得到这个图像: 死AVPlayer

我可以使用safari打开流,它工作正常.我还使用Apple的HTTP Live Streaming Tools验证了流

我现在有点卡住了.有任何想法吗?

推荐阅读
贴进你的心聆听你的世界
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有