BMPPlayerView

Objective-C


@interface BMPPlayerView
    : UIView <BMPUserInterfaceApi, BMPUserInterfaceEventHandler>

Swift

class PlayerView : UIView, UserInterfaceApi, UserInterfaceEventHandler

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, or using the according property if the view is created using the interface builder.

@discussion If you are composing the view via the interface builder make sure you use the obj-c class name BMPPlayerView

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
          }
      }
  • Undocumented

    Declaration

    Objective-C

    @property (nullable, nonatomic, strong) id<BMPPlayer> player

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic, weak) id<BMPFullscreenHandler> _Nullable fullscreenHandler;

    Swift

    weak var fullscreenHandler: FullscreenHandler? { get set }
  • Creates a new instance of the PlayerView.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithPlayer:(nonnull id<BMPPlayer>)player
                                     frame:(CGRect)frame;

    Swift

    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

  • When the hosting App supports more UIDeviceOrientation this method should be called before the view will rotate.

    Note

    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

    Objective-C

    - (void)willRotate;

    Swift

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

    Note

    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

    Objective-C

    - (void)didRotate;

    Swift

    func didRotate()