I am trying to stream HLS video using an AVPlayer embedded in an AVPlayerViewController. To do this I am doing the following to setup an AVPlayerViewController, following the apple docs here: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);
}
}
}
this all works fine. But when I change the url to
let url = NSURL.init(string: "http://cdn-fms.rbs.com.br/hls-vod/sample1_1500kbps.f4v.m3u8") // but this one doesn't
or any other HLS stream it doesn't work anymore. I get this image: dead AVPlayer
I can open the stream using safari and it works fine. I have also validated the stream using the Apple's HTTP Live Streaming Tools
I am a bit stuck now. Any ideas?