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 interface
ExoMediaPlayback.Listener
Interface definition to listen for player states.protected static interface
ExoMediaPlayback.PlaybackAction
-
Field Summary
Fields Modifier and Type Field Description protected static int
ACTION_PAUSE
protected static int
ACTION_PLAY
protected com.google.android.exoplayer2.source.MediaSourceEventListener
adaptiveMediaSourceEventListener
protected android.content.Context
context
protected com.google.android.exoplayer2.drm.DrmSessionEventListener
drmEventListener
protected long
fromSeekPosition
protected android.os.Handler
mainHandler
protected PlayerBandwidthMeter
playerBandwidthMeter
protected long
playheadPosition
protected int
progressInterval
static java.util.ResourceBundle
resourceBundle
protected long
seekPosition
-
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 void
add(int index, Video video)
Adds the video to the video list at the specified index.void
add(Video video)
Adds the video to the end of the video list.void
addAll(int index, java.util.Collection<Video> newVideos)
Inserts all videos in the collection at the specified index.void
addAll(java.util.Collection<Video> newVideos)
Add all videos in the collection to the end of the list.void
addListener(ExoMediaPlayback.Listener listener)
protected com.google.android.exoplayer2.upstream.DataSource.Factory
buildDataSourceFactory(com.google.android.exoplayer2.upstream.HttpDataSource.Factory httpDatasourceFactory, boolean useBandwidthMeter)
Returns a new DataSource factory.void
clear()
Removes all videos from the list.void
destroyPlayer()
Destroys the current player and releases it from memory.void
emitErrorEvent(java.lang.String message)
Emits an error event with the message passed in the event's propertiesvoid
emitErrorEvent(java.lang.String message, java.lang.Exception exception)
Emits an error event including the message passed and the exception in the propertiesprotected void
finalize()
boolean
getAllowHlsChunklessPreparation()
Analytics
getAnalytics()
Returns the analytics component, the part of the player that monitors and tracks video playback and engagement.com.google.android.exoplayer2.Format
getAudioFormat()
com.google.android.exoplayer2.upstream.BandwidthMeter
getBandwidthMeter()
Returns the current bandwidth meter.int
getBufferPercentage()
Returns the buffer percentageint
getCurrentIndex()
Gets the index from the current videolong
getCurrentPosition()
Returns the current playhead position of the underlying video player.Source
getCurrentSource()
Get the current source for theVideo
.Video
getCurrentVideo()
Get the currently playing video.com.google.android.exoplayer2.upstream.HttpDataSource.Factory
getDataSourceFactory()
Returns the currentHttpDataSource.Factory
, which is used when creating theMediaSource
.com.google.android.exoplayer2.DefaultRenderersFactory
getDefaultRenderersFactory()
Gets the DefaultRenderersFactory object.ExoPlayerDrmSessionManager
getExoPlayerDrmSessionManager()
Gets the ExoPlayer Drm session if available or null otherwise.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).LoadControlConfig
getLoadControlConfig()
Gets the LoadControlConfig object.android.os.Handler
getMainHandler()
long
getMaxBufferDurationToSwitchDown()
Deprecated.It is not longer used for ExoPlayer v2.long
getMinBufferDurationToSwitchUp()
Deprecated.It is not longer used for ExoPlayer v2.int
getMinBufferMs()
Deprecated.It is not longer used for ExoPlayer v2.int
getMinRebufferMs()
Deprecated.It is not longer used for ExoPlayer v2.BrightcoveNotification
getNotification()
Get the object which handles showing an on-going player notification.int
getPeakBitrate()
Return the peak bitrate.android.os.Looper
getPlaybackLooper()
com.google.android.exoplayer2.ExoPlayer
getPlayer()
Get the player used for media playback.int
getPlayerState()
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.DefaultSourceSelectionController
getSourceController()
The source selector which uses a delegate to select sources.com.google.android.exoplayer2.trackselection.DefaultTrackSelector
getTrackSelector()
Gets the DefaultTrackSelector object.TrackSelectorHelper
getTrackSelectorHelper()
Gets the TrackSelectorHelper object.Video
getVideoAt(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.Format
getVideoFormat()
float
getVolume()
WidevineMediaDrmCallback
getWidevineMediaDrmCallback()
boolean
hasDvr()
Indicates if the current stream is a live video with DVR.protected void
initializeListeners()
boolean
isCurrentVideo360Mode()
Returns true if the video is a 360 video otherwise returns falseboolean
isInLiveEdge()
Checks the current playhead position with the live edge position and determines if it is within range of the live edge.boolean
isLive()
Indicates whether the current stream is a live video.boolean
isPlaying()
boolean
isPlayingAudioOnly()
Check if the player is currently playing and the media is audio-only.boolean
isSourceSet()
Returns if a source has been setprotected void
onHandlePlayPauseAction(int state)
Handle internal state and events for play/pause.void
onTaskRemoved(android.content.Intent rootIntent)
This is called when theMediaPlaybackService
is currently running and the user has removed a task that comes from the service's application.void
openCurrentVideoSource()
Prepares the player to play the current video source.void
openVideo(Video video, Source source)
Creates, configures, and prepares a new instance of MediaPlaybackvoid
pause()
Convenience method for easily pausing the exoplayer.void
play(long position)
Convenience method for easily starting the exoplayer.void
remove(int index)
Removes the video at the specified index.boolean
removeListener(ExoMediaPlayback.Listener listener)
void
replace(int index, Video video)
Removes and replaces the video at the specified index.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 captionsvoid
setBandwidthMeter(com.google.android.exoplayer2.upstream.BandwidthMeter bandwidthMeter)
Sets the current bandwidth meter.void
setCaptionListener(ExoPlayerVideoDisplayComponent.CaptionListener listener)
void
setCurrentIndex(int index)
Sets the current video to the specified index.void
setDataSourceFactory(com.google.android.exoplayer2.upstream.HttpDataSource.Factory httpDataSourceFactory)
Sets theHttpDataSource.Factory
, which is used when creating theMediaSource
.void
setDebugListener(ExoPlayerVideoDisplayComponent.InfoListener debugListener)
void
setDefaultRenderersFactory(com.google.android.exoplayer2.DefaultRenderersFactory defaultRenderersFactory)
ExoMediaPlayback
setEventEmitter(EventEmitter eventEmitter)
This is used to reset the EventEmitter when restoring the playback from the service.void
setInternalErrorListener(ExoPlayerVideoDisplayComponent.InternalErrorListener internalErrorListener)
void
setLoadControlConfig(LoadControlConfig loadControlConfig)
Sets the LoadControlConfig object.void
setMaxBufferDurationToSwitchDown(long maxBufferDurationToSwitchDown)
Deprecated.It is not longer used for ExoPlayer v2.void
setMinBufferDurationToSwitchUp(long minBufferDurationToSwitchUp)
Deprecated.It is not longer used for ExoPlayer v2.void
setMinBufferMs(int minBufferMs)
Deprecated.It is not longer used for ExoPlayer v2.void
setMinRebufferMs(int minRebufferMs)
Deprecated.It is not longer used for ExoPlayer v2.void
setNotificationConfig(PlaybackNotification.Config config)
Configure the on-going notification.void
setPeakBitrate(int peakBitrate)
Sets the peak bitrate.void
setProgressInterval(int progressInterval)
Sets the the interval in milliseconds at which to fire PROGRESS events during playback.void
setTrackSelectionOverrideCreator(TrackSelectionOverrideCreator creator)
Provides a creator for aTrackSelectionOverrides.TrackSelectionOverride
instance specific for the Video track.void
setTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector trackSelector)
void
setVideoDisplayProperties(java.util.Map<java.lang.String,java.lang.String> videoDisplayProperties)
Video
setVideoPath(java.lang.String path)
Replaces player content with the video at the specified path.Video
setVideoPath(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.void
setVideoSelectionOverrideCreator(SelectionOverrideCreator creator)
Deprecated.void
setVideoSource(Video video, Source source)
Sets the video source that will be used for playback.protected void
startUpdater()
protected void
stopUpdater()
-
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. TheExoPlayerDrmSessionManager
will be created only when the currentSource
properties 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:MediaPlayback
This is called when theMediaPlaybackService
is currently running and the user has removed a task that comes from the service's application.- Specified by:
onTaskRemoved
in 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:MediaPlayback
Get the object which handles showing an on-going player notification.- Specified by:
getNotification
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
- Returns:
- An object to configure the on-going playback notification.
-
getSourceController
public DefaultSourceSelectionController getSourceController()
Description copied from interface:MediaPlayback
The source selector which uses a delegate to select sources.- Specified by:
getSourceController
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
- Returns:
- A source controller
-
getPlaylist
public java.util.List<Video> getPlaylist()
Description copied from interface:MediaPlayback
Returns a immutable copy of the video list.- Specified by:
getPlaylist
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
isPlaying
public boolean isPlaying()
- Specified by:
isPlaying
in 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:MediaPlayback
Replaces player content with the video at the specified path.- Specified by:
setVideoPath
in 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:MediaPlayback
Replace player content with the video and captions at the specified paths.- Specified by:
setVideoPath
in 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:MediaPlayback
Adds the video to the end of the video list.- Specified by:
add
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
add
public void add(int index, Video video) throws java.lang.IndexOutOfBoundsException
Description copied from interface:MediaPlayback
Adds the video to the video list at the specified index.- Specified by:
add
in 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:MediaPlayback
Add all videos in the collection to the end of the list.- Specified by:
addAll
in 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.IndexOutOfBoundsException
Description copied from interface:MediaPlayback
Inserts all videos in the collection at the specified index.- Specified by:
addAll
in 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:MediaPlayback
Gets a video from the video list at the specified index- Specified by:
getVideoAt
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
getCurrentIndex
public int getCurrentIndex()
Description copied from interface:MediaPlayback
Gets the index from the current video- Specified by:
getCurrentIndex
in 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.IndexOutOfBoundsException
Description copied from interface:MediaPlayback
Sets the current video to the specified index.- Specified by:
setCurrentIndex
in 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.IndexOutOfBoundsException
Description copied from interface:MediaPlayback
Removes the video at the specified index.- Specified by:
remove
in 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:MediaPlayback
Removes all videos from the list.- Specified by:
clear
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
getBufferPercentage
public int getBufferPercentage()
Description copied from interface:MediaPlayback
Returns the buffer percentage- Specified by:
getBufferPercentage
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
getVolume
public float getVolume()
- Specified by:
getVolume
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
isSourceSet
public boolean isSourceSet()
Description copied from interface:MediaPlayback
Returns if a source has been set- Specified by:
isSourceSet
in 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:MediaPlayback
Emits an error event with the message passed in the event's properties- Specified by:
emitErrorEvent
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
emitErrorEvent
public void emitErrorEvent(java.lang.String message, java.lang.Exception exception)
Description copied from interface:MediaPlayback
Emits an error event including the message passed and the exception in the properties- Specified by:
emitErrorEvent
in 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:MediaPlayback
Indicates if the current stream is a live video with DVR.- Specified by:
hasDvr
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
- Returns:
TRUE
iff live video with DVR capabilities is supported.
-
isLive
public boolean isLive()
Description copied from interface:MediaPlayback
Indicates whether the current stream is a live video.- Specified by:
isLive
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
- Returns:
TRUE
iff live video is supported.
-
isInLiveEdge
public boolean isInLiveEdge()
Description copied from interface:MediaPlayback
Checks the current playhead position with the live edge position and determines if it is within range of the live edge.- Specified by:
isInLiveEdge
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
- Returns:
- true if in live edge.
-
getCurrentPosition
public long getCurrentPosition()
Description copied from interface:MediaPlayback
Returns the current playhead position of the underlying video player.If the player has not been set or initialized,
Constants.TIME_UNSET
will returned.- Specified by:
getCurrentPosition
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
- Returns:
- the current playhead position.
-
getPlayer
public com.google.android.exoplayer2.ExoPlayer getPlayer()
Description copied from interface:MediaPlayback
Get the player used for media playback.- Specified by:
getPlayer
in 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:
getLiveEdge
in 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:
setVideoSource
in 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:
setProgressInterval
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
- Parameters:
progressInterval
- the PROGRESS interval in milliseconds
-
getCurrentVideo
@Nullable public Video getCurrentVideo()
Description copied from interface:MediaPlayback
Get the currently playing video.- Specified by:
getCurrentVideo
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
- Returns:
- The current media object.
-
getCurrentSource
@Nullable public Source getCurrentSource()
Description copied from interface:MediaPlayback
Get the current source for theVideo
.- Specified by:
getCurrentSource
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
- Returns:
- The source used for playback.
-
isPlayingAudioOnly
public boolean isPlayingAudioOnly()
Description copied from interface:MediaPlayback
Check if the player is currently playing and the media is audio-only.- Specified by:
isPlayingAudioOnly
in 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:MediaPlayback
Returns the analytics component, the part of the player that monitors and tracks video playback and engagement.- Specified by:
getAnalytics
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
- Returns:
- the analytics component
-
openCurrentVideoSource
public void openCurrentVideoSource()
Description copied from interface:MediaPlayback
Prepares the player to play the current video source.- Specified by:
openCurrentVideoSource
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
openVideo
public void openVideo(@NonNull Video video, @Nullable Source source)
Description copied from interface:MediaPlayback
Creates, configures, and prepares a new instance of MediaPlayback- Specified by:
openVideo
in 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:MediaPlayback
Returns true if the video is a 360 video otherwise returns false- Specified by:
isCurrentVideo360Mode
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
-
destroyPlayer
public void destroyPlayer()
Description copied from interface:MediaPlayback
Destroys 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:
destroyPlayer
in interfaceMediaPlayback<com.google.android.exoplayer2.ExoPlayer>
- See Also:
MediaPlayer
,SurfaceView
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in 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.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.
-
setTrackSelectionOverrideCreator
public void setTrackSelectionOverrideCreator(@NonNull TrackSelectionOverrideCreator creator)
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 thesetPeakBitrate(int)
is set.If you want to disable the default TrackSelectionOverride, you may pass
TrackSelectionOverrideCreator.EMPTY
, which returnsTrackSelectionOverrideCreator.EMPTY_TRACK_SELECTION_OVERRIDES
and gets ignored when attempting to apply it to theDefaultTrackSelector
.
-
replace
public void replace(int index, Video video)
Description copied from interface:MediaPlayback
Removes and replaces the video at the specified index.- Specified by:
replace
in 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_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 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
LoadControl
instance. TheLoadControl
is 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)
-
-