Search code examples
avplayertvosavplayerviewcontroller

Seekbar visibility callback with AVPlayerViewController in tvOS


I'm working on a solution to display some elements on screen while the seekbar is visible.

I have a AVPlayerViewController with a AVPlayer playing a video. I want to display some components while the seekbar is visible and hide them when the seekbar is hidden.

Is there a way to be notified when the seekbar is visible/hidden?

Thanks in advance.


Solution

  • Take a look at the AVPlayerViewControllerDelegate specifically this method:

    optional func playerViewController(_ playerViewController: AVPlayerViewController, willTransitionToVisibilityOfTransportBar visible: Bool, with coordinator: AVPlayerViewControllerAnimationCoordinator)
    

    More information can be found here: https://developer.apple.com/documentation/avkit/avplayerviewcontrollerdelegate/2876484-playerviewcontroller