Hello I want to play m3u8 file using swift. My m3u8 file structure is like this.
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM- INF:BANDWIDTH=814508,CODECS="avc1.66.51,mp4a.40.34",RESOLUTION=720x576 chunklist_w247403833.m3u8
But this is not playing. But if I used apple sample m3u8 file in here its playing. but above m3u8 file is playing in android app and windows vlc player too. What would be the reason for this? Please help me. Thanks
code
let videoURL = NSURL(string: "http://74.208.128.124:1935/live/myStream/playlist.m3u8")//http://devstreaming.apple.com/videos/wwdc/2016/102w0bsn0ge83qfv7za/102/hls_vod_mvp.m3u8
let player = AVPlayer(url: videoURL! as URL)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = self.view.bounds
self.view.layer.addSublayer(playerLayer)
player.play()
}
Adding KVO
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if keyPath=="status"
{
if(player.status==AVPlayerStatus.readyToPlay)
{
print(player.status)
}
else if(player.status==AVPlayerStatus.failed)
{
print("ERROR-----------", player.status)
}
}
}