PlayerView

@available(iOS 14.0, tvOS 14.0, *)
@objcMembers
@objc(BMPPlayerView)
open class PlayerView : UIView
extension PlayerView: UIScrollViewDelegate
extension PlayerView: UserInterfaceApi
extension PlayerView: UserInterfaceEventHandler
extension PlayerView: _PlayerListenerInternal

A view that provides the Bitmovin Player UI and default UI handling to an attached Player instance. This view needs a Player instance to work properly. This Player can be passed to the initializer.

If a custom UI is preferred, an AVPlayerLayer or an AVPlayerViewController can be registered via registerPlayerLayer / registerPlayerViewController. See PlayerView for more details.

// Create a subclass of UIView
class CustomView: UIView {
    init(player: Player, frame: CGRect) {
        super.init(frame: frame)

        // register the AVPlayerLayer of this view to the Player
        player.register(playerLayer)
    }

    var playerLayer: AVPlayerLayer {
        layer as! AVPlayerLayer
    }

    override class var layerClass: AnyClass {
        AVPlayerLayer.self
    }
}
  • Declaration

    Swift

    public var player: Player? { get set }
  • Get/set a fullscreen handler for this PlayerView. See the documentation of the FullscreenHandler for more information.

    Declaration

    Swift

    public weak var fullscreenHandler: FullscreenHandler? { get set }
  • The SystemUiApi for interactions regarding the system UI. Using this API just has an effect if userInterfaceType in StyleConfig is set to .system. This is the default value on tvOS, on iOS it has to be set specifically.

    Declaration

    Swift

    public private(set) var systemUi: SystemUiApi? { get }
  • The PictureInPictureApi for interactions regarding picture in picture feature. Using this API just has an effect if pictureInPicture is enabled. Is nil if pictureInPicture is not enabled.

    Declaration

    Swift

    public private(set) var pictureInPicture: PictureInPictureApi? { get }
  • The PlayerViewEventsApi for interactions regarding event publishers. This API is only available for usage from Swift.

    Declaration

    Swift

    public let events: PlayerViewEventsApi
  • Creates a new instance of the PlayerView.

    Declaration

    Swift

    public init(
        player: Player,
        frame: CGRect
    )

    Parameters

    player

    The Player instance which will be associated with this PlayerView instance

    frame

    The CGRect which will be passed to the UIView initializer

  • Creates a new instance of the PlayerView.

    Declaration

    Swift

    public init(
        player: Player,
        frame: CGRect,
        playerViewConfig: PlayerViewConfig
    )

    Parameters

    player

    The Player instance which will be associated with this PlayerView instance

    frame

    The CGRect which will be passed to the UIView initializer

    playerViewConfig

    A configuration object for the PlayerView instance

  • Declaration

    Swift

    override public func didMoveToSuperview()
  • When the hosting App supports more UIDeviceOrientations this method should be called before the view will rotate.

    This can be implemented inside the viewWillTransition method.

    override func viewWillTransition(
        to size: CGSize,
        with coordinator: UIViewControllerTransitionCoordinator
    ) {
        playerView.willRotate()
        coordinator.animate(
            alongsideTransition: { _ in
                // ...
            },
            completion: { _ in
                playerView.didRotate()
            }
        )
    
        super.viewWillTransition(to: size, with: coordinator)
    }
    

    Declaration

    Swift

    public func willRotate()
  • When the hosting App supports more UIDeviceOrientations this method should be called after the view rotated.

    This can be implemented inside the viewWillTransition method.

    override func viewWillTransition(
        to size: CGSize,
        with coordinator: UIViewControllerTransitionCoordinator
    ) {
        playerView.willRotate()
        coordinator.animate(
            alongsideTransition: { _ in
                // ...
            },
            completion: { _ in
                playerView.didRotate()
            }
        )
    
        super.viewWillTransition(to: size, with: coordinator)
    }
    

    Declaration

    Swift

    public func didRotate()
  • Declaration

    Swift

    public func viewForZooming(in scrollView: UIScrollView) -> UIView?
  • Declaration

    Swift

    public func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool
  • Declaration

    Swift

    public var isFullscreen: Bool { get }
  • Declaration

    Swift

    public var areControlsShown: Bool { get }
  • Declaration

    Swift

    public var isPictureInPictureAvailable: Bool { get }
  • Declaration

    Swift

    public var isPictureInPicture: Bool { get }
  • Declaration

    Swift

    public var scalingMode: ScalingMode { get set }
  • Declaration

    Swift

    public func enterPictureInPicture()
  • Declaration

    Swift

    public func exitPictureInPicture()
  • Declaration

    Swift

    public func enterFullscreen()
  • Declaration

    Swift

    public func exitFullscreen()
  • Declaration

    Swift

    public func setPosterImage(url: URL, keepPersistent: Bool)
  • Declaration

    Swift

    public func setSubtitleStyles(_ subtitleStyles: [AVTextStyleRule]?)
  • Declaration

    Swift

    public func add(listener: UserInterfaceListener)
  • Declaration

    Swift

    public func remove(listener: UserInterfaceListener)
  • Declaration

    Swift

    @available(tvOS, unavailable)
    public func onCastWaiting(
        forDevice event: CastWaitingForDeviceEvent,
        player: Player
    )
  • Declaration

    Swift

    public func onInternalAdPlaybackDidRequestContentPause(
        _ event: _InternalAdPlaybackDidRequestContentPauseEvent,
        player: Player
    )
  • Declaration

    Swift

    public func onInternalAdPlaybackDidRequestContentResume(
        _ event: _InternalAdPlaybackDidRequestContentResumeEvent,
        player: Player
    )