Here's how you can listen to player state changes and hide / show buttons: (suppose your player has a name playerand a button playButton)
player.addObserver(self, forKeyPath: "rate", options: .New, context: nil) // somewhere after player init
...
override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
if keyPath == "rate" {
playButton.enabled = player.rate == 1
} else {
super.observeValueForKeyPath(keyPath, ofObject: object, change: change, context: context)
}
}
If the player’s speed is 0, this means that the video is not playing.
source
share