I want to be able to hold a reference to the AVPlayer
instance that takes over the screen when playing HTML videos full screen from embedded browsers. My first approach was this:
extension AVPlayerViewController {
override public func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
print("herezzzzzzzzzzzzzzzzzzzzzzzzzzz") // prints correctly
print(self.player) // prints nil
}
}
However it always returns nil. So I'm trying a different approach. I want to override either the initializer or play
method of AVPlayer but I can't seem to do it without getting objective-c selector conflicts.
import AVKit
import MediaPlayer
extension AVPlayer {
override func play() { // this doesn't work. just an example of what i want
super.play()
print("do stuff here")
}
}
Is there a way to override one of AVPlayer's instance methods so I can store a reference to self
? Or is it not even an AVPlayer?