Class ExoMediaPlayback
- java.lang.Object
-
- com.brightcove.player.event.AbstractComponent
-
- com.brightcove.player.playback.ExoMediaPlayback
-
- All Implemented Interfaces:
Component,MediaPlayback<com.google.android.exoplayer2.ExoPlayer>
@Emits(events={"bufferedUpdate","completed","didInterruptContent","didPause","didPlay","didResumeContent","didSeekTo","didSetSource","didStop","error","pause","play","progress","sourceNotPlayable","stop","videoDurationChanged","willChangeVideo","addAnalyticsBaseParams","analyticsVideoEngagement","audioTracks","bufferingCompleted","bufferingStarted","caption","captionsLanguages","toggleClosedCaptions","seekToIncorrectTargetValue","didChangeList","setVideo","setSource","selectSource","didSelectSource","didSetVideo","sourceNotFound","setVideoStill","volumeChange","renditionChanged"}) @ListensFor(events={"pause","play","seekTo","setSource","stop","willInterruptContent","willResumeContent","didSetAnalyticsBaseParams","setVolume","didSetVideo","didPlay","didSeekTo","resumeFromCastSession","selectAudioTrack","selectClosedCaptionTrack","on360FrameAvailable"}) @RestrictTo(LIBRARY) public class ExoMediaPlayback extends AbstractComponent implements MediaPlayback<com.google.android.exoplayer2.ExoPlayer>
This class extends the VideoDisplayComponent to add support for the ExoPlayer.See: https://github.com/google/ExoPlayer
- See Also:
VideoDisplayComponent
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceExoMediaPlayback.ListenerInterface definition to listen for player states.protected static interfaceExoMediaPlayback.PlaybackAction
-
Field Summary
Fields Modifier and Type Field Description protected static intACTION_PAUSEprotected static intACTION_PLAYprotected com.google.android.exoplayer2.source.MediaSourceEventListeneradaptiveMediaSourceEventListenerprotected android.content.Contextcontextprotected com.google.android.exoplayer2.drm.DrmSessionEventListenerdrmEventListenerprotected longfromSeekPositionprotected android.os.HandlermainHandlerprotected PlayerBandwidthMeterplayerBandwidthMeterprotected longplayheadPositionprotected intprogressIntervalstatic java.util.ResourceBundleresourceBundleprotected longseekPosition-
Fields inherited from class com.brightcove.player.event.AbstractComponent
eventEmitter, listenerTokens
-
-
Constructor Summary
Constructors Constructor Description ExoMediaPlayback(android.content.Context context, EventEmitter eventEmitter)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(int index, Video video)Adds the video to the video list at the specified index.voidadd(Video video)Adds the video to the end of the video list.voidaddAll(int index, java.util.Collection<Video> newVideos)Inserts all videos in the collection at the specified index.voidaddAll(java.util.Collection<Video> newVideos)Add all videos in the collection to the end of the list.voidaddListener(ExoMediaPlayback.Listener listener)protected com.google.android.exoplayer2.upstream.DataSource.FactorybuildDataSourceFactory(com.google.android.exoplayer2.upstream.HttpDataSource.Factory httpDatasourceFactory, boolean useBandwidthMeter)Returns a new DataSource factory.voidclear()Removes all videos from the list.voiddestroyPlayer()Destroys the current player and releases it from memory.voidemitErrorEvent(java.lang.String message)Emits an error event with the message passed in the event's propertiesvoidemitErrorEvent(java.lang.String message, java.lang.Exception exception)Emits an error event including the message passed and the exception in the propertiesprotected voidfinalize()booleangetAllowHlsChunklessPreparation()AnalyticsgetAnalytics()Returns the analytics component, the part of the player that monitors and tracks video playback and engagement.com.google.android.exoplayer2.FormatgetAudioFormat()com.google.android.exoplayer2.upstream.BandwidthMetergetBandwidthMeter()Returns the current bandwidth meter.intgetBufferPercentage()Returns the buffer percentageintgetCurrentIndex()Gets the index from the current videolonggetCurrentPosition()Returns the current playhead position of the underlying video player.SourcegetCurrentSource()Get the current source for theVideo.VideogetCurrentVideo()Get the currently playing video.com.google.android.exoplayer2.upstream.HttpDataSource.FactorygetDataSourceFactory()Returns the currentHttpDataSource.Factory, which is used when creating theMediaSource.com.google.android.exoplayer2.DefaultRenderersFactorygetDefaultRenderersFactory()Gets the DefaultRenderersFactory object.ExoPlayerDrmSessionManagergetExoPlayerDrmSessionManager()Gets the ExoPlayer Drm session if available or null otherwise.longgetLiveEdge()Compute the "live edge" as a long datatype, the largest position not within three target durations of the duration (per the HLS spec).LoadControlConfiggetLoadControlConfig()Gets the LoadControlConfig object.android.os.HandlergetMainHandler()longgetMaxBufferDurationToSwitchDown()Deprecated.It is not longer used for ExoPlayer v2.longgetMinBufferDurationToSwitchUp()Deprecated.It is not longer used for ExoPlayer v2.intgetMinBufferMs()Deprecated.It is not longer used for ExoPlayer v2.intgetMinRebufferMs()Deprecated.It is not longer used for ExoPlayer v2.BrightcoveNotificationgetNotification()Get the object which handles showing an on-going player notification.intgetPeakBitrate()Return the peak bitrate.android.os.LoopergetPlaybackLooper()com.google.android.exoplayer2.ExoPlayergetPlayer()Get the player used for media playback.intgetPlayerState()Returns the ExoPlayer state if available, or -1 if the player is null.java.util.List<Video>getPlaylist()Returns a immutable copy of the video list.DefaultSourceSelectionControllergetSourceController()The source selector which uses a delegate to select sources.com.google.android.exoplayer2.trackselection.DefaultTrackSelectorgetTrackSelector()Gets the DefaultTrackSelector object.TrackSelectorHelpergetTrackSelectorHelper()Gets the TrackSelectorHelper object.VideogetVideoAt(int index)Gets a video from the video list at the specified indexjava.util.Map<java.lang.String,java.lang.String>getVideoDisplayProperties()com.google.android.exoplayer2.FormatgetVideoFormat()floatgetVolume()WidevineMediaDrmCallbackgetWidevineMediaDrmCallback()booleanhasDvr()Indicates if the current stream is a live video with DVR.protected voidinitializeListeners()booleanisCurrentVideo360Mode()Returns true if the video is a 360 video otherwise returns falsebooleanisInLiveEdge()Checks the current playhead position with the live edge position and determines if it is within range of the live edge.booleanisLive()Indicates whether the current stream is a live video.booleanisPlaying()booleanisPlayingAudioOnly()Check if the player is currently playing and the media is audio-only.booleanisSourceSet()Returns if a source has been setprotected voidonHandlePlayPauseAction(int state)Handle internal state and events for play/pause.voidonTaskRemoved(android.content.Intent rootIntent)This is called when theMediaPlaybackServiceis currently running and the user has removed a task that comes from the service's application.voidopenCurrentVideoSource()Prepares the player to play the current video source.voidopenVideo(Video video, Source source)Creates, configures, and prepares a new instance of MediaPlaybackvoidpause()Convenience method for easily pausing the exoplayer.voidplay(long position)Convenience method for easily starting the exoplayer.voidremove(int index)Removes the video at the specified index.booleanremoveListener(ExoMediaPlayback.Listener listener)voidreplace(int index, Video video)Removes and replaces the video at the specified index.voidsetAllowHlsChunklessPreparation(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 captionsvoidsetBandwidthMeter(com.google.android.exoplayer2.upstream.BandwidthMeter bandwidthMeter)Sets the current bandwidth meter.voidsetCaptionListener(ExoPlayerVideoDisplayComponent.CaptionListener listener)voidsetCurrentIndex(int index)Sets the current video to the specified index.voidsetDataSourceFactory(com.google.android.exoplayer2.upstream.HttpDataSource.Factory httpDataSourceFactory)Sets theHttpDataSource.Factory, which is used when creating theMediaSource.voidsetDebugListener(ExoPlayerVideoDisplayComponent.InfoListener debugListener)voidsetDefaultRenderersFactory(com.google.android.exoplayer2.DefaultRenderersFactory defaultRenderersFactory)ExoMediaPlaybacksetEventEmitter(EventEmitter eventEmitter)This is used to reset the EventEmitter when restoring the playback from the service.voidsetInternalErrorListener(ExoPlayerVideoDisplayComponent.InternalErrorListener internalErrorListener)voidsetLoadControlConfig(LoadControlConfig loadControlConfig)Sets the LoadControlConfig object.voidsetMaxBufferDurationToSwitchDown(long maxBufferDurationToSwitchDown)Deprecated.It is not longer used for ExoPlayer v2.voidsetMinBufferDurationToSwitchUp(long minBufferDurationToSwitchUp)Deprecated.It is not longer used for ExoPlayer v2.voidsetMinBufferMs(int minBufferMs)Deprecated.It is not longer used for ExoPlayer v2.voidsetMinRebufferMs(int minRebufferMs)Deprecated.It is not longer used for ExoPlayer v2.voidsetNotificationConfig(PlaybackNotification.Config config)Configure the on-going notification.voidsetPeakBitrate(int peakBitrate)Sets the peak bitrate.voidsetProgressInterval(int progressInterval)Sets the the interval in milliseconds at which to fire PROGRESS events during playback.voidsetTrackSelectionOverrideCreator(TrackSelectionOverrideCreator creator)Provides a creator for aTrackSelectionOverrides.TrackSelectionOverrideinstance specific for the Video track.voidsetTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector trackSelector)voidsetVideoDisplayProperties(java.util.Map<java.lang.String,java.lang.String> videoDisplayProperties)VideosetVideoPath(java.lang.String path)Replaces player content with the video at the specified path.VideosetVideoPath(java.lang.String videoPath, java.util.Map<java.lang.String,java.lang.String> languageCodeCaptionsMap)Replace player content with the video and captions at the specified paths.voidsetVideoSelectionOverrideCreator(SelectionOverrideCreator creator)Deprecated.voidsetVideoSource(Video video, Source source)Sets the video source that will be used for playback.protected voidstartUpdater()protected voidstopUpdater()-
Methods inherited from class com.brightcove.player.event.AbstractComponent
addListener, addOnceListener, getEventEmitter, removeListener, removeListeners
-
-
-
-
Field Detail
-
ACTION_PLAY
protected static final int ACTION_PLAY
- See Also:
- Constant Field Values
-
ACTION_PAUSE
protected static final int ACTION_PAUSE
- See Also:
- Constant Field Values
-
resourceBundle
public static java.util.ResourceBundle resourceBundle
-
progressInterval
protected int progressInterval
-
mainHandler
protected final android.os.Handler mainHandler
-
playheadPosition
protected long playheadPosition
-
seekPosition
protected long seekPosition
-
context
protected final android.content.Context context
-
playerBandwidthMeter
protected final PlayerBandwidthMeter playerBandwidthMeter
-
fromSeekPosition
protected long fromSeekPosition
-
drmEventListener
protected final com.google.android.exoplayer2.drm.DrmSessionEventListener drmEventListener
-
adaptiveMediaSourceEventListener
protected final com.google.android.exoplayer2.source.MediaSourceEventListener adaptiveMediaSourceEventListener
-
-
Constructor Detail
-
ExoMediaPlayback
public ExoMediaPlayback(android.content.Context context, EventEmitter eventEmitter)
-
-
Method Detail
-
addListener
public void addListener(ExoMediaPlayback.Listener listener)
-
removeListener
public boolean removeListener(ExoMediaPlayback.Listener listener)
-
getExoPlayerDrmSessionManager
public ExoPlayerDrmSessionManager getExoPlayerDrmSessionManager()
Gets the ExoPlayer Drm session if available or null otherwise. TheExoPlayerDrmSessionManagerwill be created only when the currentSourceproperties has the keySource.Fields.WIDEVINE_KEY_SYSTEM- Returns:
- the drm session manager
-
getWidevineMediaDrmCallback
public WidevineMediaDrmCallback getWidevineMediaDrmCallback()
-
onTaskRemoved
public void onTaskRemoved(android.content.Intent rootIntent)
Description copied from interface:MediaPlaybackThis is called when theMediaPlaybackServiceis currently running and the user has removed a task that comes from the service's application.- Specified by:
onTaskRemovedin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Parameters:
rootIntent- The original Intent that was used to launch the task that is being removed.
-
getNotification
@Nullable public BrightcoveNotification getNotification()
Description copied from interface:MediaPlaybackGet the object which handles showing an on-going player notification.- Specified by:
getNotificationin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
- An object to configure the on-going playback notification.
-
getSourceController
public DefaultSourceSelectionController getSourceController()
Description copied from interface:MediaPlaybackThe source selector which uses a delegate to select sources.- Specified by:
getSourceControllerin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
- A source controller
-
getPlaylist
public java.util.List<Video> getPlaylist()
Description copied from interface:MediaPlaybackReturns a immutable copy of the video list.- Specified by:
getPlaylistin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
isPlaying
public boolean isPlaying()
- Specified by:
isPlayingin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
- True if the player is currently playing.
-
setVideoPath
public Video setVideoPath(java.lang.String path)
Description copied from interface:MediaPlaybackReplaces player content with the video at the specified path.- Specified by:
setVideoPathin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Parameters:
path- HTTP path to a video- Returns:
- The created Video object.
-
setVideoPath
public Video setVideoPath(java.lang.String videoPath, java.util.Map<java.lang.String,java.lang.String> languageCodeCaptionsMap)
Description copied from interface:MediaPlaybackReplace player content with the video and captions at the specified paths.- Specified by:
setVideoPathin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Parameters:
videoPath- HTTP path to the videolanguageCodeCaptionsMap- A map of language code to caption urls.
-
add
public void add(Video video)
Description copied from interface:MediaPlaybackAdds the video to the end of the video list.- Specified by:
addin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
add
public void add(int index, Video video) throws java.lang.IndexOutOfBoundsExceptionDescription copied from interface:MediaPlaybackAdds the video to the video list at the specified index.- Specified by:
addin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Throws:
java.lang.IndexOutOfBoundsException- when index < 0 or index is larger than the size of the video list.
-
addAll
public void addAll(java.util.Collection<Video> newVideos)
Description copied from interface:MediaPlaybackAdd all videos in the collection to the end of the list.- Specified by:
addAllin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Parameters:
newVideos- The videos to append.
-
addAll
public void addAll(int index, java.util.Collection<Video> newVideos) throws java.lang.IndexOutOfBoundsExceptionDescription copied from interface:MediaPlaybackInserts all videos in the collection at the specified index.- Specified by:
addAllin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Throws:
java.lang.IndexOutOfBoundsException- when index < 0 or index is larger than the size of the video list.
-
getVideoAt
public Video getVideoAt(int index)
Description copied from interface:MediaPlaybackGets a video from the video list at the specified index- Specified by:
getVideoAtin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
getCurrentIndex
public int getCurrentIndex()
Description copied from interface:MediaPlaybackGets the index from the current video- Specified by:
getCurrentIndexin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
- The index of the current video or -1 if there are none.
-
setCurrentIndex
public void setCurrentIndex(int index) throws java.lang.IndexOutOfBoundsExceptionDescription copied from interface:MediaPlaybackSets the current video to the specified index.- Specified by:
setCurrentIndexin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Throws:
java.lang.IndexOutOfBoundsException- when index < 0 or index is larger than the size of the video list.
-
remove
public void remove(int index) throws java.lang.IndexOutOfBoundsExceptionDescription copied from interface:MediaPlaybackRemoves the video at the specified index.- Specified by:
removein interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Throws:
java.lang.IndexOutOfBoundsException- when index < 0 or index is larger than the size of the video list.
-
clear
public void clear()
Description copied from interface:MediaPlaybackRemoves all videos from the list.- Specified by:
clearin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
getBufferPercentage
public int getBufferPercentage()
Description copied from interface:MediaPlaybackReturns the buffer percentage- Specified by:
getBufferPercentagein interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
getVolume
public float getVolume()
- Specified by:
getVolumein interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
isSourceSet
public boolean isSourceSet()
Description copied from interface:MediaPlaybackReturns if a source has been set- Specified by:
isSourceSetin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
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)
-
setNotificationConfig
public void setNotificationConfig(PlaybackNotification.Config config)
Configure the on-going notification.- Parameters:
config- The configuration to apply to the notification.
-
emitErrorEvent
public void emitErrorEvent(java.lang.String message)
Description copied from interface:MediaPlaybackEmits an error event with the message passed in the event's properties- Specified by:
emitErrorEventin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
emitErrorEvent
public void emitErrorEvent(java.lang.String message, java.lang.Exception exception)Description copied from interface:MediaPlaybackEmits an error event including the message passed and the exception in the properties- Specified by:
emitErrorEventin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
setEventEmitter
@RestrictTo(LIBRARY) public ExoMediaPlayback setEventEmitter(EventEmitter eventEmitter)
This is used to reset the EventEmitter when restoring the playback from the service.- Parameters:
eventEmitter- The new event emitter to set for this playback instance.- Returns:
- This playback instance
-
initializeListeners
protected void initializeListeners()
-
startUpdater
protected void startUpdater()
-
stopUpdater
protected void stopUpdater()
-
hasDvr
public boolean hasDvr()
Description copied from interface:MediaPlaybackIndicates if the current stream is a live video with DVR.- Specified by:
hasDvrin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
TRUEiff live video with DVR capabilities is supported.
-
isLive
public boolean isLive()
Description copied from interface:MediaPlaybackIndicates whether the current stream is a live video.- Specified by:
isLivein interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
TRUEiff live video is supported.
-
isInLiveEdge
public boolean isInLiveEdge()
Description copied from interface:MediaPlaybackChecks the current playhead position with the live edge position and determines if it is within range of the live edge.- Specified by:
isInLiveEdgein interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
- true if in live edge.
-
getCurrentPosition
public long getCurrentPosition()
Description copied from interface:MediaPlaybackReturns the current playhead position of the underlying video player.If the player has not been set or initialized,
Constants.TIME_UNSETwill returned.- Specified by:
getCurrentPositionin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
- the current playhead position.
-
getPlayer
public com.google.android.exoplayer2.ExoPlayer getPlayer()
Description copied from interface:MediaPlaybackGet the player used for media playback.- Specified by:
getPlayerin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
- The media player.
-
getLiveEdge
public long getLiveEdge()
Compute the "live edge" as a long datatype, the largest position not within three target durations of the duration (per the HLS spec).- Specified by:
getLiveEdgein interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- 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)
-
setInternalErrorListener
public void setInternalErrorListener(ExoPlayerVideoDisplayComponent.InternalErrorListener internalErrorListener)
-
setVideoSource
public void setVideoSource(@Nullable Video video, @Nullable Source source)Sets the video source that will be used for playback.- Specified by:
setVideoSourcein interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Parameters:
video- reference to the video, if any.source- reference to the video source, if any.
-
setProgressInterval
public void setProgressInterval(int progressInterval)
Sets the the interval in milliseconds at which to fire PROGRESS events during playback. The default is 500ms.- Specified by:
setProgressIntervalin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Parameters:
progressInterval- the PROGRESS interval in milliseconds
-
getCurrentVideo
@Nullable public Video getCurrentVideo()
Description copied from interface:MediaPlaybackGet the currently playing video.- Specified by:
getCurrentVideoin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
- The current media object.
-
getCurrentSource
@Nullable public Source getCurrentSource()
Description copied from interface:MediaPlaybackGet the current source for theVideo.- Specified by:
getCurrentSourcein interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
- The source used for playback.
-
isPlayingAudioOnly
public boolean isPlayingAudioOnly()
Description copied from interface:MediaPlaybackCheck if the player is currently playing and the media is audio-only.- Specified by:
isPlayingAudioOnlyin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
- True if the player is currently playing audio-only media; false otherwise.
-
getAnalytics
public Analytics getAnalytics()
Description copied from interface:MediaPlaybackReturns the analytics component, the part of the player that monitors and tracks video playback and engagement.- Specified by:
getAnalyticsin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Returns:
- the analytics component
-
openCurrentVideoSource
public void openCurrentVideoSource()
Description copied from interface:MediaPlaybackPrepares the player to play the current video source.- Specified by:
openCurrentVideoSourcein interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
openVideo
public void openVideo(@NonNull Video video, @Nullable Source source)Description copied from interface:MediaPlaybackCreates, configures, and prepares a new instance of MediaPlayback- Specified by:
openVideoin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Parameters:
video- reference to the video to be prepared for the playback.source- reference to the source to played if any.
-
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
-
isCurrentVideo360Mode
public boolean isCurrentVideo360Mode()
Description copied from interface:MediaPlaybackReturns true if the video is a 360 video otherwise returns false- Specified by:
isCurrentVideo360Modein interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
destroyPlayer
public void destroyPlayer()
Description copied from interface:MediaPlaybackDestroys the current player and releases it from memory. This helps to manage working with the complex state machines that are the MediaPlayer and the SurfaceView- Specified by:
destroyPlayerin interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- See Also:
MediaPlayer,SurfaceView
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
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)
-
play
public void play(long position)
Convenience method for easily starting the exoplayer.
-
pause
public void pause()
Convenience method for easily pausing the exoplayer.
-
onHandlePlayPauseAction
protected void onHandlePlayPauseAction(int state)
Handle internal state and events for play/pause.
-
getPlaybackLooper
public android.os.Looper getPlaybackLooper()
-
getMainHandler
public android.os.Handler getMainHandler()
-
getVideoFormat
public com.google.android.exoplayer2.Format getVideoFormat()
-
getAudioFormat
public com.google.android.exoplayer2.Format getAudioFormat()
-
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 creator)Deprecated.Provides a creator for aDefaultTrackSelector.SelectionOverrideinstance specific for the Video track.This SelectionOverride is applied every time a new video is loaded, and when the
setPeakBitrate(int)is set.
-
setTrackSelectionOverrideCreator
public void setTrackSelectionOverrideCreator(@NonNull TrackSelectionOverrideCreator creator)Provides a creator for a
TrackSelectionOverrides.TrackSelectionOverrideinstance specific for the Video track. This TrackSelectionOverride is applied every time a new video is loaded, and when thesetPeakBitrate(int)is set.If you want to disable the default TrackSelectionOverride, you may pass
TrackSelectionOverrideCreator.EMPTY, which returnsTrackSelectionOverrideCreator.EMPTY_TRACK_SELECTION_OVERRIDESand gets ignored when attempting to apply it to theDefaultTrackSelector.
-
replace
public void replace(int index, Video video)Description copied from interface:MediaPlaybackRemoves and replaces the video at the specified index.- Specified by:
replacein interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>- Parameters:
index- The index to replace a media item.video- The video to replace
-
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 currentHttpDataSource.Factory, which is used when creating theMediaSource.
-
setDataSourceFactory
public void setDataSourceFactory(@NonNull com.google.android.exoplayer2.upstream.HttpDataSource.Factory httpDataSourceFactory)Sets theHttpDataSource.Factory, which is used when creating theMediaSource. WARNING: When creating a customized HttpDataSource.Factory, you must make sure to use the default user agentC.HTTP_USER_AGENTto 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 UsegetLoadControlConfig()
-
setMinRebufferMs
@Deprecated public void setMinRebufferMs(int minRebufferMs)
Deprecated.It is not longer used for ExoPlayer v2. UsesetLoadControlConfig(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
LoadControlinstance. TheLoadControlis used when creating an instance of the ExoPlayer.- Parameters:
loadControlConfig- the load control config
-
buildDataSourceFactory
protected com.google.android.exoplayer2.upstream.DataSource.Factory buildDataSourceFactory(com.google.android.exoplayer2.upstream.HttpDataSource.Factory httpDatasourceFactory, boolean useBandwidthMeter)Returns a new DataSource factory.- Parameters:
httpDatasourceFactory- contains RequestProperties information (such as Video request headers)useBandwidthMeter- specifies whether the transfer operations must be tracked using the bandwidth meter.- Returns:
- A new DataSource factory.
-
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)
-
-