Created
February 22, 2019 09:50
-
-
Save pgpt10/ea8e13e50cf2e6cae0ded838978a974f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override public func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { | |
if keyPath == "timeControlStatus", let change = change, let newValue = change[NSKeyValueChangeKey.newKey] as? Int, let oldValue = change[NSKeyValueChangeKey.oldKey] as? Int { | |
let oldStatus = AVPlayer.TimeControlStatus(rawValue: oldValue) | |
let newStatus = AVPlayer.TimeControlStatus(rawValue: newValue) | |
if newStatus != oldStatus { | |
DispatchQueue.main.async {[weak self] in | |
if newStatus == .playing || newStatus == .paused { | |
self?.loaderView.isHidden = true | |
} else { | |
self?.loaderView.isHidden = false | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment