Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 1.53 KB

avPlayer.md

File metadata and controls

51 lines (34 loc) · 1.53 KB

AVPlayer

Listeners

Observer to see when the video playback started

player = AVPlayer(url: URL(fileURLWithPath: path))
player.addObserver(self, forKeyPath: "rate", options: NSKeyValueObservingOptions.new, context: nil)

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
    if keyPath == "rate" {
        if player.rate > 0 {
            print("video started")
        }
    }
}

Knowing when AVPlayer object is ready to play

How to detect AVPlayer actually started to play in swift

Selecting Tracks AV Media Playback

Selecting Subtitles and Alternative Audio Tracks

AVAsset

Media playback

Muting Audio

if IsMuted == false {
      IsMuted = true
      musicPlayer.volume = 0
    } else {
      IsMuted = false
      musicPlayer.volume = 1
    }
}