Search code examples
swiftavplayertvosapple-tvavplayerviewcontroller

AppleTv - CustomOverlayViewController force popup at timecode


I'm using the CustomOverlayViewController on an AVPlayerViewController to display movies related to what the user is currently watching. (https://developer.apple.com/documentation/avkit/avplayerviewcontroller/3229856-customoverlayviewcontroller)

CustomOverlayViewController

I want to bring that up into focus automatically when the credits start playing. I have a timecode in my metadata and can detect when that occurs. But, I can't find a way to force the view to popup without the user swiping to it on the remote. Is there a way to force this view into focus without user input?

P.S. It is fine if it can be accessed at other times manually by the user as well. I just need to be able to also autofocus it at a certain point.


Solution

  • I ran into the same issue and instead of using the customOverlayViewController property of AVPlayerViewController, I just call

    vcToPresent = ViewController()
    vcToPresent.modalPresentationStyle = .overCurrentContext
    self.avPlayerVC?.present(vcToPresent, animated: true, completion: nil)
    

    to present the desired VC on screen at the time you want it to display.