Answer the question
In order to leave comments, you need to log in
Restore Stream AVPlayer on error?
Hey!
I'm making an IPTV player, it's simple!
var player: AVPlayer?
func setupPlayerView(_ urlString: String) {
if let url = URL(string: urlString) {
player = AVPlayer(url: url)
let playerLayer = AVPlayerLayer(player: player)
self.layer.addSublayer(playerLayer)
playerLayer.frame = self.frame
player?.play()
}
}
Answer the question
In order to leave comments, you need to log in
1. Add an observer in viewDidLoad
2. Check status
// catch changes to status
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if keyPath == "status" {
// do something
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question