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

  • Constructor Details

    • ExoPlayerVideoDisplayComponent

      public ExoPlayerVideoDisplayComponent(RenderView renderView, EventEmitter eventEmitter)
  • Method Details

    • getBrightcoveDrmSession

      @Nullable @Deprecated public BrightcoveDrmSession getBrightcoveDrmSession()
      Deprecated.
      Deprecates. Instead use {getExoPlayerDrmSessionManager()}
    • getExoPlayerDrmSessionManager

      public ExoPlayerDrmSessionManager getExoPlayerDrmSessionManager()
      Gets the ExoPlayer Drm session if available or null otherwise. The ExoPlayerDrmSessionManager will be created only when the current Source properties has the key Source.Fields.WIDEVINE_KEY_SYSTEM
      Returns:
      the drm session manager
    • getWidevineMediaDrmCallback

      public WidevineMediaDrmCallback getWidevineMediaDrmCallback()
    • onCreatePlayback

      public ExoMediaPlayback onCreatePlayback()
      Description copied from class: VideoDisplayComponent
      Called when the VideoDisplayComponent is initialized.
      Overrides:
      onCreatePlayback in class VideoDisplayComponent
      Returns:
      The media playback for the component.
    • createPlayback

      public ExoMediaPlayback createPlayback()
      Description copied from class: VideoDisplayComponent
      Create the MediaPlayback for the VideoDisplayComponent.
      Overrides:
      createPlayback in class VideoDisplayComponent
      Returns:
      A new instance of MediaPlayback.
    • getPlayback

      public ExoMediaPlayback getPlayback()
      Description copied from class: VideoDisplayComponent
      Get the current playback.
      Overrides:
      getPlayback in class VideoDisplayComponent
      Returns:
      The MediaPlayback for this VideoDisplayComponent.
    • getCurrentVideo

      @Nullable public Video getCurrentVideo()
      Description copied from class: VideoDisplayComponent
      Gets reference to the video that is currently configured for playback, if any
      Overrides:
      getCurrentVideo in class VideoDisplayComponent
      Returns:
      null or reference to the video
    • getCurrentSource

      @Nullable public Source getCurrentSource()
      Description copied from class: VideoDisplayComponent
      Gets reference to the video source that is currently configured for playback, if any
      Overrides:
      getCurrentSource in class VideoDisplayComponent
      Returns:
      null or reference to the video source
    • 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:
    • setTrackSelector

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

      protected void initializeListeners()
      Overrides:
      initializeListeners in class VideoDisplayComponent
    • getMediaPlayer

      public android.media.MediaPlayer getMediaPlayer()
      Overrides:
      getMediaPlayer in class VideoDisplayComponent
    • 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.
    • getPlayerCurrentPosition

      public long getPlayerCurrentPosition()
      Description copied from class: VideoDisplayComponent
      Returns the current playhead position of the underlying video player.

      If the player has not been set or initialized, Constants.TIME_UNSET will returned.

      Overrides:
      getPlayerCurrentPosition in class VideoDisplayComponent
      Returns:
      the current playhead position.
    • 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()
    • setDebugListener

      public void setDebugListener(ExoPlayerVideoDisplayComponent.InfoListener debugListener)
    • setCaptionListener

      public void setCaptionListener(ExoPlayerVideoDisplayComponent.CaptionListener listener)
    • setMetadataListener

      public void setMetadataListener(ExoPlayerVideoDisplayComponent.MetadataListener listener)
    • getMetadataListener

    • getId3MetadataListener

      public ExoPlayerVideoDisplayComponent.Id3MetadataListener getId3MetadataListener()
    • setMetadataListener

      @Deprecated public void setMetadataListener(ExoPlayerVideoDisplayComponent.Id3MetadataListener listener)
      Parameters:
      listener - the listener
    • setInternalErrorListener

      public void setInternalErrorListener(ExoPlayerVideoDisplayComponent.InternalErrorListener internalErrorListener)
    • setTextInformationFrameListener

      public void setTextInformationFrameListener(@NonNull TextInformationFrameListener listener)
      Description copied from class: VideoDisplayComponent
      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.

      Overrides:
      setTextInformationFrameListener in class VideoDisplayComponent
      Parameters:
      listener - the listener
    • 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
    • setVideoSelectionOverrideCreator

      @Deprecated public void setVideoSelectionOverrideCreator(@NonNull SelectionOverrideCreator videoSelectionOverrideCreator)

      Provides a creator for a DefaultTrackSelector.SelectionOverride instance specific for the Video track. This SelectionOverride is applied every time a new video is loaded, and when the setPeakBitrate(int) is set.

      If you want to disable the default SelectionOverride, you may pass SelectionOverrideCreator.EMPTY, which returns SelectionOverrideCreator.EMPTY_SELECTION_OVERRIDE and gets ignored when attempting to apply it to the DefaultTrackSelector.

    • setVideoTrackSelectionOverrideCreator

      public void setVideoTrackSelectionOverrideCreator(@NonNull TrackSelectionOverrideCreator videoTrackSelectionOverrideCreator)

      Provides a creator for a TrackSelectionOverrides.TrackSelectionOverride instance specific for the Video track. This TrackSelectionOverride is applied every time a new video is loaded, and when the setPeakBitrate(int) is set.

      If you want to disable the default TrackSelectionOverride, you may pass TrackSelectionOverrideCreator.EMPTY, which returns TrackSelectionOverrideCreator.EMPTY_TRACK_SELECTION_OVERRIDES and gets ignored when attempting to apply it to the DefaultTrackSelector.

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

      @Deprecated public void setMinRebufferMs(int minRebufferMs)
      Deprecated.
      It is not longer used for ExoPlayer v2. Use setLoadControlConfig(LoadControlConfig)
    • 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
    • surfaceCreated

      public void surfaceCreated(android.view.SurfaceHolder surfaceHolder)
      Overrides:
      surfaceCreated in class VideoDisplayComponent
    • surfaceChanged

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

      public void surfaceDestroyed(android.view.SurfaceHolder surfaceHolder)
      Overrides:
      surfaceDestroyed in class VideoDisplayComponent
    • isCurrentMediaAudioOnly

      public boolean isCurrentMediaAudioOnly()
      Overrides:
      isCurrentMediaAudioOnly in class VideoDisplayComponent
    • getVideoDisplayProperties

      public Map<String,String> getVideoDisplayProperties()
    • setVideoDisplayProperties

      public void setVideoDisplayProperties(Map<String,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
    • getUseDrmSessionsForClearContent

      public boolean getUseDrmSessionsForClearContent()
      Returns:
      Whether to use the DRM session with clear content sections in the media (e.g. for DRM content with clear stitched-in ads)
    • setUseDrmSessionsForClearContent

      public void setUseDrmSessionsForClearContent(boolean useDrmSessionsForClearContent)
      Whether to use the DRM session with clear content sections in the media (e.g. for DRM content with clear stitched-in ads)
    • 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)