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:
  • Field Details

    • ON_PLAY_SEEK_THRESHOLD

      @Deprecated protected static final int ON_PLAY_SEEK_THRESHOLD
      Deprecated.
      See Also:
    • isFrameAvailable

      @Deprecated protected boolean isFrameAvailable
      Deprecated.
    • renderView

      protected RenderView renderView
    • fromSeekPosition

      @Deprecated protected long fromSeekPosition
      Deprecated.
    • context

      protected android.content.Context context
    • updater

      @Deprecated protected ScheduledFuture<?> updater
      Deprecated.
    • hasSurface

      protected boolean hasSurface
    • seekPosition

      @Deprecated protected long seekPosition
      Deprecated.
    • reseeking

      @Deprecated protected boolean reseeking
      Deprecated.
    • playheadPosition

      @Deprecated protected int playheadPosition
      Deprecated.
    • playheadPositionLong

      @Deprecated protected long playheadPositionLong
      Deprecated.
    • nextVideo

      @Deprecated protected Video nextVideo
      Deprecated.
    • nextSource

      @Deprecated protected Source nextSource
      Deprecated.
    • captionsPath

      @Deprecated protected String captionsPath
      Deprecated.
    • progressInterval

      @Deprecated protected int progressInterval
      Deprecated.
    • mRendererConfig

      protected RendererConfig mRendererConfig
    • shouldPlayAudioOnlyInBackground

      protected boolean shouldPlayAudioOnlyInBackground
  • Constructor Details

  • Method Details

    • 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:
      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:
      IllegalStateException - if there is no source configured.
    • setRendererConfig

      public void setRendererConfig(RendererConfig rendererConfig)
    • onCreatePlayback

      protected MediaPlayback<?> onCreatePlayback()
      Called when the VideoDisplayComponent is initialized.
      Returns:
      The media playback for the component.
    • createPlayback

      public MediaPlayback<?> createPlayback()
      Create the MediaPlayback for the VideoDisplayComponent.
      Returns:
      A new instance of MediaPlayback.
    • getPlayback

      public MediaPlayback getPlayback()
      Get the current playback.
      Returns:
      The MediaPlayback for this VideoDisplayComponent.
    • 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

      @Deprecated protected void initializeListeners()
      Deprecated.
    • getAnalytics

      public Analytics getAnalytics()
    • getRenderView

      public RenderView getRenderView()
    • getMediaPlayer

      public android.media.MediaPlayer getMediaPlayer()
    • 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:
      NullPointerException - if video is null.
    • getHeaders

      protected static Map<String,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(String message)
    • emitErrorEvent

      protected void emitErrorEvent(String message, Exception exception)
    • isCurrentVideo360Mode

      public boolean isCurrentVideo360Mode()
    • shouldPlayAudioOnlyInBackground

      public boolean shouldPlayAudioOnlyInBackground()
    • setShouldPlayAudioOnlyInBackground

      public void setShouldPlayAudioOnlyInBackground(boolean play)
    • isCurrentMediaAudioOnly

      public boolean isCurrentMediaAudioOnly()
    • 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