Class 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
    • Field Detail

      • ON_PLAY_SEEK_THRESHOLD

        protected static final int ON_PLAY_SEEK_THRESHOLD
        See Also:
        Constant Field Values
      • isFrameAvailable

        protected boolean isFrameAvailable
      • 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
    • Constructor Detail

    • 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()