Hi, guys
I am making a project that plays video using Swift AVPlayer. There is a problem that the video stops, or there is only sound but no video. When a video URL is received and played through AVPlyer, the file extension is HLS (.m3u8) Same issue with both AVPlayer and Safari. However, it plays normally in Chrome. Is it a video file problem? Or is there something the app needs to handle?
This is the sample video URL I am using
-
https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8
-
https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8
-
http://d3rlna7iyyu8wu.cloudfront.net/skip_armstrong/skip_armstrong_stereo_subs.m3u8
self.playerItem = AVPlayerItem(url: URL(string: urlString)!)
self.playerItem?.addObserver(self, forKeyPath: #keyPath(AVPlayerItem.status), options: [.initial, .new], context: &self.playerItemContext)
self.playerItemObserver = true
if self.player == nil {
self.player = AVPlayer(playerItem: self.playerItem)
self.playerLayer = AVPlayerLayer(player: self.player)
self.player?.play()
return
}
I am using the above code to insert the url and play it.