How to detect AVPlayer actually started to play in swift

后端 未结 7 1471
情话喂你
情话喂你 2020-12-16 10:59

Hello I have set my UISliderminimum value to 0.00. Then I set it\'s max value in this way.

self.viewPlayer.layer.addSublayer(playerLayer)
    le         


        
7条回答
  •  暖寄归人
    2020-12-16 11:25

    You can add an observer on the object of your AVPlayer like this

    player.addObserver(self, forKeyPath: "status", options: NSKeyValueObservingOptions.new, context: nil)
    

    and you can check the status change with your AVPlayer like this

     func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutableRawPointer) {
        if keyPath == "status" {
            print(player.status)
        }
    }
    

提交回复
热议问题