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?
"The most important classes used for playing video content within that UIWebView are called MPAVController and UIMoviePlayerController". So you can't get the instance of AVPlayer.
Please check this question: How to receive NSNotifications from UIWebView embedded YouTube video playback for more detail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With