com.brightcove.player.display

## Class VideoDisplayComponent

- java.lang.Object
- - com.brightcove.player.event.AbstractComponent
  - - com.brightcove.player.display.VideoDisplayComponent

- All Implemented Interfaces:
    Component
  Direct Known Subclasses:
    ExoPlayerVideoDisplayComponent

      @Emits(events={"bufferedUpdate","completed","didInterruptContent","didPause","didPlay","didResumeContent","didSeekTo","didSetSource","didStop","error","pause","play","progress","sourceNotPlayable","stop","videoDurationChanged","videoSizeKnown","willChangeVideo","readyToPlay"})
       @ListensFor(events={"completed","didSetSource","pause","play","prebufferNextVideo","seekTo","setSource","stop","videoDurationChanged","willChangeVideo","willInterruptContent","willResumeContent","readyToPlay","setVolume","didSetVideo","on360FrameAvailable","didSeekTo"})
      public class VideoDisplayComponent
      extends AbstractComponent

  The VideoDisplayComponent wraps the Brightcove EventEmitter around the lifecycle of the standard Android MediaPlayer API. The intended goal is that the end developer should never have to interact directly with the MediaPlayer instance, but rather only have to fire events at it via the EventEmitter.
  LifeCycle
  To begin playing, the VideoDisplayComponent (VDC) must first receive a EventType.SET_SOURCE event, containing a valid Source parameter. Once the source is set, the VDC will emit EventType.DID_SET_SOURCE.
  Once set, the the VDC will respond to the following events:
  - EventType.PLAY: plays the video / resumes playback if paused
  - EventType.PAUSE: pauses the video
  - EventType.SEEK_TO: seeks to the position
  - EventType.STOP: stops the video and destroys the player
  In addition, the VDC will emit Progress , buffering, and video_completed events.
  See Also:
    `MediaPlayer`, `Source`, `AbstractComponent`, `EventEmitter`, `EventType`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `VideoDisplayComponent.OnSetSourceListener`
    `protected class` | `VideoDisplayComponent.OnWillChangeVideoListener`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `captionsPath`
    `protected android.content.Context` | `context`
    `protected long` | `fromSeekPosition`
    `protected boolean` | `hasSurface`
    `protected boolean` | `isFrameAvailable`
    `protected RendererConfig` | `mRendererConfig`
    `protected Source` | `nextSource`
    `protected Video` | `nextVideo`
    `protected static int` | `ON_PLAY_SEEK_THRESHOLD`
    `protected int` | `playheadPosition` Deprecated.
    `protected long` | `playheadPositionLong`
    `protected int` | `progressInterval`
    `protected RenderView` | `renderView`
    `protected boolean` | `reseeking`
    `protected long` | `seekPosition`
    `protected java.util.concurrent.ScheduledFuture<?>` | `updater`

    - ### Fields inherited from class com.brightcove.player.event.AbstractComponent

      `eventEmitter, listenerTokens`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `VideoDisplayComponent(RenderView renderView, EventEmitter eventEmitter)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `destroyPlayer()` Destroys the current player and releases it from memory.
    `protected void` | `emitErrorEvent(java.lang.String message)`
    `protected void` | `emitErrorEvent(java.lang.String message, java.lang.Exception exception)`
    `protected void` | `emitVideoSize(int width, int height)`
    `Analytics` | `getAnalytics()`
    `Source` | `getCurrentSource()` Gets reference to the video source that is currently configured for playback, if any
    `Source` | `getCurrentSourceOrFail()` Gets reference to the video source that is currently configured for playback, if any
    `Video` | `getCurrentVideo()` Gets reference to the video that is currently configured for playback, if any
    `Video` | `getCurrentVideoOrFail()` Gets reference to the video that is currently configured for playback, if any
    `protected static java.util.Map<java.lang.String,java.lang.String>` | `getHeaders(Video video, Source source)`
    `int` | `getLiveEdge()` Deprecated.
    `long` | `getLiveEdgeLong()` Obtains the playhead position of the "live edge".
    `android.media.MediaPlayer` | `getMediaPlayer()`
    `long` | `getPlayerCurrentPosition()` Returns the current playhead position of the underlying video player.
    `RenderView` | `getRenderView()`
    `boolean` | `hasDvr()` Indicates if Live with DVR is supported.
    `protected void` | `initializeListeners()`
    `boolean` | `isCurrentVideo360Mode()`
    `boolean` | `isInLiveEdge()` Checks the current playhead position with the live edge position and determines if it is in live edge.
    `boolean` | `isLive()` Provides a default for handling live videos.
    `void` | `onSurfaceTextureAvailable(android.graphics.SurfaceTexture surfaceTexture, int width, int height)`
    `void` | `onSurfaceTextureDestroyed(android.graphics.SurfaceTexture surfaceTexture)`
    `void` | `onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture surfaceTexture, int width, int height)`
    `void` | `onSurfaceTextureUpdated(android.graphics.SurfaceTexture surfaceTexture)`
    `protected void` | `openCurrentVideoSource()` Prepares the player to play the current video source.
    `protected void` | `openVideo(Video video, Source source)` Creates, configures, and prepares a new instance of MediaPlayer
    `void` | `setProgressInterval(int progressInterval)` Sets the the interval in milliseconds at which to fire PROGRESS events during playback.
    `void` | `setRendererConfig(RendererConfig rendererConfig)`
    `void` | `setTextInformationFrameListener(TextInformationFrameListener listener)` Sets the Text Information Frame Listener.
    `protected void` | `setVideoSource(Video video, Source source)` Sets the video source that will be used for playback.
    `protected void` | `startUpdater()`
    `protected void` | `stopUpdater()`
    `void` | `surfaceChanged(android.view.SurfaceHolder surfaceHolder, int format, int width, int height)`
    `void` | `surfaceCreated(android.view.SurfaceHolder surfaceHolder)`
    `void` | `surfaceDestroyed(android.view.SurfaceHolder surfaceHolder)`

    - ### Methods inherited from class com.brightcove.player.event.AbstractComponent

      `addListener, addOnceListener, getEventEmitter, removeListener, removeListeners`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ON_PLAY_SEEK_THRESHOLD

          protected static final int ON_PLAY_SEEK_THRESHOLD

      See Also:
        Constant Field Values

    - #### isFrameAvailable

          protected boolean isFrameAvailable

    - #### renderView

          protected RenderView renderView

    - #### fromSeekPosition

          protected long fromSeekPosition

    - #### context

          protected android.content.Context context

    - #### updater

          protected java.util.concurrent.ScheduledFuture<?> updater

    - #### hasSurface

          protected boolean hasSurface

    - #### seekPosition

          protected long seekPosition

    - #### reseeking

          protected boolean reseeking

    - #### playheadPosition

          @Deprecated
          protected int playheadPosition

      Deprecated.

    - #### playheadPositionLong

          protected long playheadPositionLong

    - #### nextVideo

          protected Video nextVideo

    - #### nextSource

          protected Source nextSource

    - #### captionsPath

          protected java.lang.String captionsPath

    - #### progressInterval

          protected int progressInterval

    - #### mRendererConfig

          protected RendererConfig mRendererConfig

  - ### Constructor Detail

    - #### VideoDisplayComponent

          public VideoDisplayComponent(RenderView renderView,
                                       EventEmitter eventEmitter)

  - ### Method Detail

    - #### setVideoSource

          protected void setVideoSource(@Nullable
                                        Video video,
                                        @Nullable
                                        Source source)

      Sets the video source that will be used for playback.
      Parameters:
        `video` - reference to the video, if any.
        `source` - reference to the video source, if any.

    - #### getCurrentVideo

          @Nullable
          public Video getCurrentVideo()

      Gets reference to the video that is currently configured for playback, if any
      Returns:
        null or reference to the video

    - #### getCurrentSource

          @Nullable
          public Source getCurrentSource()

      Gets reference to the video source that is currently configured for playback, if any
      Returns:
        null or reference to the video source

    - #### getCurrentVideoOrFail

          @NonNull
          public Video getCurrentVideoOrFail()

      Gets reference to the video that is currently configured for playback, if any
      Returns:
        reference to the video
      Throws:
        `java.lang.IllegalStateException` - if there is no video configured.

    - #### getCurrentSourceOrFail

          @NonNull
          public Source getCurrentSourceOrFail()

      Gets reference to the video source that is currently configured for playback, if any
      Returns:
        reference to the video source
      Throws:
        `java.lang.IllegalStateException` - if there is no source configured.

    - #### setRendererConfig

          public void setRendererConfig(RendererConfig rendererConfig)

    - #### hasDvr

          public boolean hasDvr()

      Indicates if Live with DVR is supported. Subclasses will override if live with DVR videos are supported.
      Returns:
        `TRUE` iff live video with DVR capabilities is supported.

    - #### isLive

          public boolean isLive()

      Provides a default for handling live videos. Subclasses will override if live videos are supported.
      Returns:
        `TRUE` iff live video is supported.

    - #### getLiveEdge

          @Deprecated
          public int getLiveEdge()

      Deprecated.
      Obtains the playhead position of the "live edge".
      Returns:
        0. Subclasses should override to provide a value within three target durations of the maximum position.

    - #### getLiveEdgeLong

          public long getLiveEdgeLong()

      Obtains the playhead position of the "live edge".
      Returns:
        0. Subclasses should override to provide a value within three target durations of the maximum position.

    - #### isInLiveEdge

          public boolean isInLiveEdge()

      Checks the current playhead position with the live edge position and determines if it is in live edge.
      Returns:
        true if in live edge.

    - #### getPlayerCurrentPosition

          public long getPlayerCurrentPosition()

      Returns the current playhead position of the underlying video player. If the player has not been set or initialized, `Constants.TIME_UNSET` will returned.
      Returns:
        the current playhead position.

    - #### setProgressInterval

          public void setProgressInterval(int progressInterval)

      Sets the the interval in milliseconds at which to fire PROGRESS events during playback. The default is 500ms.
      Parameters:
        `progressInterval` - the PROGRESS interval in milliseconds

    - #### initializeListeners

          protected void initializeListeners()

    - #### startUpdater

          protected void startUpdater()

    - #### stopUpdater

          protected void stopUpdater()

    - #### getAnalytics

          public Analytics getAnalytics()

    - #### getRenderView

          public RenderView getRenderView()

    - #### getMediaPlayer

          public android.media.MediaPlayer getMediaPlayer()

    - #### openCurrentVideoSource

          protected void openCurrentVideoSource()

      Prepares the player to play the current video source.

    - #### openVideo

          protected void openVideo(@NonNull
                                   Video video,
                                   @Nullable
                                   Source source)

      Creates, configures, and prepares a new instance of MediaPlayer
      Parameters:
        `video` - reference to the video to be prepared for the playback.
        `source` - reference to the source to played if any.
      Throws:
        `java.lang.NullPointerException` - if video is null.

    - #### getHeaders

          protected static java.util.Map<java.lang.String,java.lang.String> getHeaders(Video video,
                                                                                       Source source)

    - #### destroyPlayer

          protected void destroyPlayer()

      Destroys the current player and releases it from memory. This seems wasteful, but helps to mitigate working with the complex state machines that are the MediaPlayer and the SurfaceView
      See Also:
        `MediaPlayer`, `SurfaceView`

    - #### emitVideoSize

          protected void emitVideoSize(int width,
                                       int height)

    - #### surfaceCreated

          public void surfaceCreated(android.view.SurfaceHolder surfaceHolder)

    - #### surfaceChanged

          public void surfaceChanged(android.view.SurfaceHolder surfaceHolder,
                                     int format,
                                     int width,
                                     int height)

    - #### surfaceDestroyed

          public void surfaceDestroyed(android.view.SurfaceHolder surfaceHolder)

    - #### onSurfaceTextureAvailable

          public void onSurfaceTextureAvailable(android.graphics.SurfaceTexture surfaceTexture,
                                                int width,
                                                int height)

    - #### onSurfaceTextureSizeChanged

          public void onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture surfaceTexture,
                                                  int width,
                                                  int height)

    - #### onSurfaceTextureDestroyed

          public void onSurfaceTextureDestroyed(android.graphics.SurfaceTexture surfaceTexture)

    - #### onSurfaceTextureUpdated

          public void onSurfaceTextureUpdated(android.graphics.SurfaceTexture surfaceTexture)

    - #### emitErrorEvent

          protected void emitErrorEvent(java.lang.String message)

    - #### emitErrorEvent

          protected void emitErrorEvent(java.lang.String message,
                                        java.lang.Exception exception)

    - #### isCurrentVideo360Mode

          public boolean isCurrentVideo360Mode()

    - #### setTextInformationFrameListener

          public void setTextInformationFrameListener(@NonNull
                                                      TextInformationFrameListener listener)

      Sets the Text Information Frame Listener. `TextInformationFrameListener.onTextInformationFrame(TextInformationFrame, long)` will be called when the player finds an ID3 Metadata of type `TextInformationFrame` in the Video. Use `TextInformationFrameListener.DISABLED` to disable the listener.
      Parameters:
        `listener` - the listener