Class ExoPlayerVideoDisplayComponent

  • All Implemented Interfaces:
    Component

    @Emits(events={"addAnalyticsBaseParams","analyticsVideoEngagement","audioTracks","bufferingCompleted","bufferingStarted","caption","captionsLanguages","error","toggleClosedCaptions","seekToIncorrectTargetValue"})
    @ListensFor(events={"selectAudioTrack","selectClosedCaptionTrack","on360FrameAvailable","videoDurationChanged","didSetAnalyticsBaseParams"})
    public class ExoPlayerVideoDisplayComponent
    extends VideoDisplayComponent
    This class extends the VideoDisplayComponent to add support for the ExoPlayer.

    See: https://github.com/google/ExoPlayer

    See Also:
    VideoDisplayComponent
    • Field Detail

      • BUFFERED_POSITION

        public static final java.lang.String BUFFERED_POSITION
        The buffered position property of a BUFFERED_UPDATE event.
        See Also:
        Constant Field Values
      • RENDITION_CHANGED

        public static final java.lang.String RENDITION_CHANGED
        Emitted when the ExoPlayer changes the rendition
        See Also:
        Constant Field Values
      • EXOPLAYER_FORMAT

        public static final java.lang.String EXOPLAYER_FORMAT
        The key for a Format object emitted when the ExoPlayer changes rendition.
        See Also:
        Constant Field Values
      • IN_MANIFEST_CC_URI_STR

        public static final java.lang.String IN_MANIFEST_CC_URI_STR
        See Also:
        Constant Field Values
      • resourceBundle

        public static java.util.ResourceBundle resourceBundle
    • Constructor Detail

      • ExoPlayerVideoDisplayComponent

        public ExoPlayerVideoDisplayComponent​(RenderView renderView,
                                              EventEmitter eventEmitter)
    • Method Detail

      • setVideoSource

        protected void setVideoSource​(@Nullable
                                      Video video,
                                      @Nullable
                                      Source source)
        Description copied from class: VideoDisplayComponent
        Sets the video source that will be used for playback.
        Overrides:
        setVideoSource in class VideoDisplayComponent
        Parameters:
        video - reference to the video, if any.
        source - reference to the video source, if any.
      • getTrackSelector

        @Nullable
        public com.google.android.exoplayer2.trackselection.DefaultTrackSelector getTrackSelector()
        Gets the DefaultTrackSelector object.
        Returns:
        the track selector
        See Also:
        DefaultTrackSelector
      • getTrackSelectorHelper

        @Nullable
        public TrackSelectorHelper getTrackSelectorHelper()
        Gets the TrackSelectorHelper object.
        Returns:
        the track selector helper
        See Also:
        TrackSelectorHelper
      • setTrackSelector

        public void setTrackSelector​(@NonNull
                                     com.google.android.exoplayer2.trackselection.DefaultTrackSelector trackSelector)
      • hasDvr

        public boolean hasDvr()
        Description copied from class: VideoDisplayComponent
        Indicates if Live with DVR is supported. Subclasses will override if live with DVR videos are supported.
        Overrides:
        hasDvr in class VideoDisplayComponent
        Returns:
        TRUE iff live video with DVR capabilities is supported.
      • isLive

        public boolean isLive()
        Description copied from class: VideoDisplayComponent
        Provides a default for handling live videos. Subclasses will override if live videos are supported.
        Overrides:
        isLive in class VideoDisplayComponent
        Returns:
        TRUE iff live video is supported.
      • isInLiveEdge

        public boolean isInLiveEdge()
        Description copied from class: VideoDisplayComponent
        Checks the current playhead position with the live edge position and determines if it is in live edge.
        Overrides:
        isInLiveEdge in class VideoDisplayComponent
        Returns:
        true if in live edge.
      • getLiveEdge

        @Deprecated
        public int getLiveEdge()
        Deprecated.
        Deprecated. Instead use getLiveEdgeLong()
        Overrides:
        getLiveEdge in class VideoDisplayComponent
        Returns:
        0. Subclasses should override to provide a value within three target durations of the maximum position.
      • getExoPlayer

        public com.google.android.exoplayer2.ExoPlayer getExoPlayer()
      • getLiveEdgeLong

        public long getLiveEdgeLong()
        Compute the "live edge" as a long datatype, the largest position not within three target durations of the duration (per the HLS spec).
        Overrides:
        getLiveEdgeLong in class VideoDisplayComponent
        Returns:
        -1 if the video is not live. Otherwise the largest position that is three target durations away from the duration.
      • getPlayerState

        public int getPlayerState()
        Returns the ExoPlayer state if available, or -1 if the player is null.
        Returns:
        the player state
        See Also:
        Player.getPlaybackState()
      • openVideo

        protected void openVideo​(@NonNull
                                 Video video,
                                 @Nullable
                                 Source source)
        Description copied from class: VideoDisplayComponent
        Creates, configures, and prepares a new instance of MediaPlayer
        Overrides:
        openVideo in class VideoDisplayComponent
        Parameters:
        video - reference to the video to be prepared for the playback.
        source - reference to the source to played if any.
      • destroyPlayer

        protected void destroyPlayer()
        Description copied from class: VideoDisplayComponent
        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
        Overrides:
        destroyPlayer in class VideoDisplayComponent
        See Also:
        MediaPlayer, SurfaceView
      • getPlaybackLooper

        public android.os.Looper getPlaybackLooper()
      • getMainHandler

        public android.os.Handler getMainHandler()
      • getVideoFormat

        public com.google.android.exoplayer2.Format getVideoFormat()
      • getPeakBitrate

        public int getPeakBitrate()
        Return the peak bitrate.
      • setPeakBitrate

        public void setPeakBitrate​(int peakBitrate)
        Sets the peak bitrate. Set 0 to set the default bitrate.
        Parameters:
        peakBitrate - the peak bitrate
      • getBandwidthMeter

        public com.google.android.exoplayer2.upstream.BandwidthMeter getBandwidthMeter()
        Returns the current bandwidth meter. If null, a default bandwidth meter will be used.
      • setBandwidthMeter

        public void setBandwidthMeter​(com.google.android.exoplayer2.upstream.BandwidthMeter bandwidthMeter)
        Sets the current bandwidth meter.
      • getDataSourceFactory

        @NonNull
        public com.google.android.exoplayer2.upstream.HttpDataSource.Factory getDataSourceFactory()
        Returns the current HttpDataSource.Factory, which is used when creating the MediaSource.
      • setDataSourceFactory

        public void setDataSourceFactory​(@NonNull
                                         com.google.android.exoplayer2.upstream.HttpDataSource.Factory httpDataSourceFactory)
        Sets the HttpDataSource.Factory, which is used when creating the MediaSource. WARNING: When creating a customized HttpDataSource.Factory, you must make sure to use the default user agent C.HTTP_USER_AGENT to avoid losing Brightcove Analytics and Delivery Rules support.
        Parameters:
        httpDataSourceFactory - the http data source factory
      • getMinBufferDurationToSwitchUp

        @Deprecated
        public long getMinBufferDurationToSwitchUp()
        Deprecated.
        It is not longer used for ExoPlayer v2.
        Returns the minimum duration of media that needs to be buffered for a switch to a higher quality variant to be considered.
      • setMinBufferDurationToSwitchUp

        @Deprecated
        public void setMinBufferDurationToSwitchUp​(long minBufferDurationToSwitchUp)
        Deprecated.
        It is not longer used for ExoPlayer v2.
        Sets the minimum duration of media that needs to be buffered for a switch to a higher quality variant to be considered.
      • getMaxBufferDurationToSwitchDown

        @Deprecated
        public long getMaxBufferDurationToSwitchDown()
        Deprecated.
        It is not longer used for ExoPlayer v2.
        Returns the maximum duration of media that needs to be buffered for a switch to a lower quality variant to be considered.
      • setMaxBufferDurationToSwitchDown

        @Deprecated
        public void setMaxBufferDurationToSwitchDown​(long maxBufferDurationToSwitchDown)
        Deprecated.
        It is not longer used for ExoPlayer v2.
        Sets the maximum duration of media that needs to be buffered for a switch to a lower quality variant to be considered.
      • getMinBufferMs

        @Deprecated
        public int getMinBufferMs()
        Deprecated.
        It is not longer used for ExoPlayer v2.
        Returns the minimum duration of data that must be buffered for playback to start or resume following a user action such as a seek.
      • setMinBufferMs

        @Deprecated
        public void setMinBufferMs​(int minBufferMs)
        Deprecated.
        It is not longer used for ExoPlayer v2.
        Sets the minimum duration of data that must be buffered for playback to start or resume following a user action such as a seek.
      • getMinRebufferMs

        @Deprecated
        public int getMinRebufferMs()
        Deprecated.
        It is not longer used for ExoPlayer v2. Use Use getLoadControlConfig()
      • getLoadControlConfig

        public LoadControlConfig getLoadControlConfig()
        Gets the LoadControlConfig object.
        Returns:
        the load control config
      • setLoadControlConfig

        public void setLoadControlConfig​(@NonNull
                                         LoadControlConfig loadControlConfig)
        Sets the LoadControlConfig object.

        This object is used to create a LoadControl instance. The LoadControl is used when creating an instance of the ExoPlayer.

        Parameters:
        loadControlConfig - the load control config
      • surfaceChanged

        public void surfaceChanged​(android.view.SurfaceHolder surfaceHolder,
                                   int format,
                                   int w,
                                   int h)
        Overrides:
        surfaceChanged in class VideoDisplayComponent
      • getVideoDisplayProperties

        public java.util.Map<java.lang.String,​java.lang.String> getVideoDisplayProperties()
      • setVideoDisplayProperties

        public void setVideoDisplayProperties​(java.util.Map<java.lang.String,​java.lang.String> videoDisplayProperties)
      • getAllowHlsChunklessPreparation

        public boolean getAllowHlsChunklessPreparation()
        Returns:
        Whether to allow HLS chunkless preparation in ExoPlayer
      • setAllowHlsChunklessPreparation

        public void setAllowHlsChunklessPreparation​(boolean allowHlsChunklessPreparation)
        The value of this field in the HlsMediaSource defaults to true in ExoPlayer 2.17.0 Override it here to false if your HLS delivery includes 608/708 captions
      • getDefaultRenderersFactory

        @Nullable
        public com.google.android.exoplayer2.DefaultRenderersFactory getDefaultRenderersFactory()
        Gets the DefaultRenderersFactory object.
        Returns:
        the DefaultRenderersFactory
        See Also:
        DefaultRenderersFactory
      • setDefaultRenderersFactory

        public void setDefaultRenderersFactory​(@NonNull
                                               com.google.android.exoplayer2.DefaultRenderersFactory defaultRenderersFactory)