Swift AVPlayer Video freeze

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

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.

I'm having a similar issue. Did you find any resolution for this?

Swift AVPlayer Video freeze
 
 
Q