-
- All Implemented Interfaces:
-
com.brightcove.player.event.Component
,com.brightcove.player.playback.MediaPlayback
@Emits(events = {EventType.BUFFERED_UPDATE, EventType.COMPLETED, EventType.DID_INTERRUPT_CONTENT, EventType.DID_PAUSE, EventType.DID_PLAY, EventType.DID_RESUME_CONTENT, EventType.DID_SEEK_TO, EventType.DID_SET_SOURCE, EventType.DID_STOP, EventType.ERROR, EventType.PAUSE, EventType.PLAY, EventType.SEEK_TO, EventType.PROGRESS, EventType.SOURCE_NOT_PLAYABLE, EventType.STOP, EventType.VIDEO_DURATION_CHANGED, EventType.WILL_CHANGE_VIDEO, EventType.ADD_ANALYTICS_BASE_PARAMS, EventType.ANALYTICS_VIDEO_ENGAGEMENT, EventType.AUDIO_TRACKS, EventType.BUFFERING_COMPLETED, EventType.BUFFERING_STARTED, EventType.CAPTION, EventType.CAPTIONS_LANGUAGES, EventType.TOGGLE_CLOSED_CAPTIONS, EventType.SEEK_TO_INCORRECT_TARGET_VALUE, EventType.DID_CHANGE_LIST, EventType.SET_VIDEO, EventType.SET_SOURCE, EventType.SELECT_SOURCE, EventType.DID_SELECT_SOURCE, EventType.DID_SET_VIDEO, EventType.SOURCE_NOT_FOUND, EventType.SET_VIDEO_STILL, EventType.VOLUME_CHANGE, ExoPlayerVideoDisplayComponent.RENDITION_CHANGED, EventType.WILL_INTERRUPT_CONTENT})@ListensFor(events = {EventType.PAUSE, EventType.PLAY, EventType.SEEK_TO, EventType.SET_SOURCE, EventType.STOP, EventType.WILL_INTERRUPT_CONTENT, EventType.WILL_RESUME_CONTENT, EventType.DID_SET_ANALYTICS_BASE_PARAMS, EventType.SET_VOLUME, EventType.DID_SET_VIDEO, EventType.DID_PLAY, EventType.DID_SEEK_TO, EventType.RESUME_FROM_CAST_SESSION, EventType.SELECT_AUDIO_TRACK, EventType.SELECT_CLOSED_CAPTION_TRACK, EventType.ON_FRAME_AVAILABLE})@RestrictTo(value = RestrictTo.Scope.LIBRARY) public class ExoMediaPlayback extends AbstractComponent implements MediaPlayback<ExoPlayer>
This class extends the VideoDisplayComponent to add support for the ExoPlayer.
See: https://github.com/google/ExoPlayer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
ExoMediaPlayback.Listener
Interface definition to listen for player states.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ExoMediaPlayback(Context context, EventEmitter eventEmitter)
-
Method Summary
Modifier and Type Method Description MediaStore
getMediaStore()
void
setMediaStore(MediaStore mediaStore)
Set the {MediaStore} for offline playback support void
setProgressInterval(int progressInterval)
Sets the the interval in milliseconds at which to fire PROGRESS events during playback. DefaultSourceSelectionController
getSourceController()
Handler
getMainHandler()
PlaybackNotification
getNotification()
void
setInternalErrorListener(ExoPlayerVideoDisplayComponent.InternalErrorListener internalErrorListener)
void
setDebugListener(ExoPlayerVideoDisplayComponent.InfoListener debugListener)
void
setCaptionListener(ExoPlayerVideoDisplayComponent.CaptionListener listener)
int
getPeakBitrate()
Return the peak bitrate. void
setPeakBitrate(int peakBitrate)
Sets the peak bitrate.Set 0 to set the default bitrate. boolean
isPlaying()
int
getCurrentIndex()
void
setCurrentIndex(int index)
long
getMinBufferDurationToSwitchUp()
Returns the minimum duration of media that needs to be bufferedfor a switch to a higher quality variant to be considered. void
setMinBufferDurationToSwitchUp(long minBufferDurationToSwitchUp)
Sets the minimum duration of media that needs to be bufferedfor a switch to a higher quality variant to be considered. long
getMaxBufferDurationToSwitchDown()
Returns the maximum duration of media that needs to be bufferedfor a switch to a lower quality variant to be considered. void
setMaxBufferDurationToSwitchDown(long maxBufferDurationToSwitchDown)
Sets the maximum duration of media that needs to be bufferedfor a switch to a lower quality variant to be considered. int
getMinBufferMs()
Returns the minimum duration of data that must be buffered forplayback to start or resume following a user action such as aseek. void
setMinBufferMs(int minBufferMs)
Sets the minimum duration of data that must be buffered forplayback to start or resume following a user action such as aseek. int
getMinRebufferMs()
void
setMinRebufferMs(int minRebufferMs)
LoadControlConfig
getLoadControlConfig()
Gets the LoadControlConfig object. void
setLoadControlConfig(@NonNull() LoadControlConfig loadControlConfig)
Sets the LoadControlConfig object. Analytics
getAnalytics()
DefaultTrackSelector
getTrackSelector()
Gets the DefaultTrackSelector object. void
setTrackSelector(@NonNull() DefaultTrackSelector trackSelector)
TrackSelectorHelper
getTrackSelectorHelper()
Gets the TrackSelectorHelper object. Video
getCurrentVideo()
Source
getCurrentSource()
Map<String, String>
getVideoDisplayProperties()
void
setVideoDisplayProperties(Map<String, String> videoDisplayProperties)
List<Video>
getPlaylist()
DefaultRenderersFactory
getDefaultRenderersFactory()
Gets the DefaultRenderersFactory object. void
setDefaultRenderersFactory(@NonNull() DefaultRenderersFactory defaultRenderersFactory)
boolean
getAllowHlsChunklessPreparation()
void
setAllowHlsChunklessPreparation(boolean allowHlsChunklessPreparation)
The value of this field in the HlsMediaSource defaults to true in ExoPlayer 2.17. boolean
getUseDrmSessionsForClearContent()
void
setUseDrmSessionsForClearContent(boolean useDrmSessionsForClearContent)
Whether to use the DRM session with clear content sections in the media(e.g. Boolean
isUsingBumper()
void
addListener(ExoMediaPlayback.Listener listener)
boolean
removeListener(ExoMediaPlayback.Listener listener)
ExoPlayerDrmSessionManager
getExoPlayerDrmSessionManager()
Gets the ExoPlayer Drm session if available or null otherwise. WidevineMediaDrmCallback
getWidevineMediaDrmCallback()
void
onTaskRemoved(Intent rootIntent)
void
setPlaybackNotification(PlaybackNotification playbackNotification)
static PlaybackNotification
getPlaybackNotification()
Static method to access the notification Video
setVideoPath(String path)
Video
setVideoPath(String videoPath, Map<String, String> languageCodeCaptionsMap)
void
add(Video video)
void
add(int index, Video video)
void
addAll(Collection<Video> newVideos)
void
addAll(int index, Collection<Video> newVideos)
Video
getVideoAt(int index)
void
remove(int index)
void
clear()
int
getBufferPercentage()
float
getVolume()
boolean
isSourceSet()
void
setNotificationConfig(PlaybackNotificationConfig config)
Configure the on-going notification. void
emitErrorEvent(String message)
void
emitErrorEvent(String message, Exception exception)
ExoMediaPlayback
setEventEmitter(EventEmitter eventEmitter)
This is used to reset the EventEmitter when restoring the playback from the service. boolean
hasDvr()
boolean
isLive()
boolean
isInLiveEdge()
long
getCurrentPosition()
ExoPlayer
getPlayer()
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). int
getPlayerState()
Returns the ExoPlayer state if available,or -1 if the player is null. void
setVideoSource(@Nullable() Video video, @Nullable() Source source)
Sets the video source that will be used for playback. boolean
isPlayingAudioOnly()
void
openCurrentVideoSource()
void
openVideo(@NonNull() Video video, @Nullable() Source source)
boolean
isCurrentVideo360Mode()
void
useBumper(boolean useBumper)
boolean
didBumperPlay()
void
bumperPlayed(boolean bumperPlayed)
void
destroyPlayer()
void
play(long position)
Convenience method for easily starting the exoplayer. void
pause()
Convenience method for easily pausing the exoplayer. void
onHandlePlayPauseAction(int state)
Handle internal state and events for play/pause. long
getDuration()
Returns the duration. Looper
getPlaybackLooper()
Format
getVideoFormat()
Format
getAudioFormat()
void
setVideoSelectionOverrideCreator(@NonNull() SelectionOverrideCreator creator)
Provides a creator for a DefaultTrackSelector.SelectionOverride instance specific forthe Video track. void
setTrackSelectionOverrideCreator(@NonNull() TrackSelectionOverrideCreator creator)
Provides a creator for a com.google.android.exoplayer2.trackselection.TrackSelectionOverride instance specific for the Video track. void
replace(int index, Video video)
BandwidthMeter
getBandwidthMeter()
Returns the current bandwidth meter. void
setBandwidthMeter(BandwidthMeter bandwidthMeter)
Sets the current bandwidth meter. HttpDataSource.Factory
getDataSourceFactory()
Returns the current HttpDataSource.Factory, which is used when creating the MediaSource. void
setDataSourceFactory(@NonNull() HttpDataSource.Factory httpDataSourceFactory)
Sets the HttpDataSource.Factory, which is used when creating the MediaSource.WARNING: When creating a customized HttpDataSource. PlaybackNotification.StreamType
getCurrentlyPlayingStreamType()
-
Methods inherited from class com.brightcove.player.event.AbstractComponent
addListener, addOnceListener, getEventEmitter, removeListener, removeListeners
-
Methods inherited from class com.brightcove.player.playback.MediaPlayback
add, addAll, clear, destroyPlayer, emitErrorEvent, getAnalytics, getBufferPercentage, getCurrentIndex, getCurrentPosition, getCurrentSource, getCurrentVideo, getLiveEdge, getNotification, getPlayer, getPlaylist, getSourceController, getVideoAt, getVolume, hasDvr, isCurrentVideo360Mode, isInLiveEdge, isLive, isPlaying, isPlayingAudioOnly, isSourceSet, onTaskRemoved, openCurrentVideoSource, openVideo, remove, replace, setCurrentIndex, setProgressInterval, setVideoPath, setVideoSource
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ExoMediaPlayback
ExoMediaPlayback(Context context, EventEmitter eventEmitter)
-
-
Method Detail
-
getMediaStore
MediaStore getMediaStore()
-
setMediaStore
void setMediaStore(MediaStore mediaStore)
Set the {MediaStore} for offline playback support
- Parameters:
mediaStore
- - The MediaStore
-
setProgressInterval
void setProgressInterval(int progressInterval)
Sets the the interval in milliseconds at which to fire PROGRESS events during playback. The default is 500ms.
- Parameters:
progressInterval
- the PROGRESS interval in milliseconds
-
getSourceController
DefaultSourceSelectionController getSourceController()
-
getMainHandler
Handler getMainHandler()
-
getNotification
PlaybackNotification getNotification()
-
setInternalErrorListener
void setInternalErrorListener(ExoPlayerVideoDisplayComponent.InternalErrorListener internalErrorListener)
-
setDebugListener
void setDebugListener(ExoPlayerVideoDisplayComponent.InfoListener debugListener)
-
setCaptionListener
void setCaptionListener(ExoPlayerVideoDisplayComponent.CaptionListener listener)
-
getPeakBitrate
int getPeakBitrate()
Return the peak bitrate.
-
setPeakBitrate
void setPeakBitrate(int peakBitrate)
Sets the peak bitrate.Set 0 to set the default bitrate.
- Parameters:
peakBitrate
- the peak bitrate
-
isPlaying
boolean isPlaying()
-
getCurrentIndex
int getCurrentIndex()
-
setCurrentIndex
void setCurrentIndex(int index)
-
getMinBufferDurationToSwitchUp
@Deprecated() long getMinBufferDurationToSwitchUp()
Returns the minimum duration of media that needs to be bufferedfor a switch to a higher quality variant to be considered.
-
setMinBufferDurationToSwitchUp
@Deprecated() void setMinBufferDurationToSwitchUp(long minBufferDurationToSwitchUp)
Sets the minimum duration of media that needs to be bufferedfor a switch to a higher quality variant to be considered.
-
getMaxBufferDurationToSwitchDown
@Deprecated() long getMaxBufferDurationToSwitchDown()
Returns the maximum duration of media that needs to be bufferedfor a switch to a lower quality variant to be considered.
-
setMaxBufferDurationToSwitchDown
@Deprecated() void setMaxBufferDurationToSwitchDown(long maxBufferDurationToSwitchDown)
Sets the maximum duration of media that needs to be bufferedfor a switch to a lower quality variant to be considered.
-
getMinBufferMs
@Deprecated() int getMinBufferMs()
Returns the minimum duration of data that must be buffered forplayback to start or resume following a user action such as aseek.
-
setMinBufferMs
@Deprecated() void setMinBufferMs(int minBufferMs)
Sets the minimum duration of data that must be buffered forplayback to start or resume following a user action such as aseek.
-
getMinRebufferMs
@Deprecated() int getMinRebufferMs()
-
setMinRebufferMs
@Deprecated() void setMinRebufferMs(int minRebufferMs)
-
getLoadControlConfig
LoadControlConfig getLoadControlConfig()
Gets the LoadControlConfig object.
-
setLoadControlConfig
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
-
getAnalytics
Analytics getAnalytics()
-
getTrackSelector
@Nullable() DefaultTrackSelector getTrackSelector()
Gets the DefaultTrackSelector object.
-
setTrackSelector
void setTrackSelector(@NonNull() DefaultTrackSelector trackSelector)
-
getTrackSelectorHelper
@Nullable() TrackSelectorHelper getTrackSelectorHelper()
Gets the TrackSelectorHelper object.
-
getCurrentVideo
@Nullable() Video getCurrentVideo()
-
getCurrentSource
@Nullable() Source getCurrentSource()
-
getVideoDisplayProperties
Map<String, String> getVideoDisplayProperties()
-
setVideoDisplayProperties
void setVideoDisplayProperties(Map<String, String> videoDisplayProperties)
-
getPlaylist
List<Video> getPlaylist()
-
getDefaultRenderersFactory
@Nullable() DefaultRenderersFactory getDefaultRenderersFactory()
Gets the DefaultRenderersFactory object.
-
setDefaultRenderersFactory
void setDefaultRenderersFactory(@NonNull() DefaultRenderersFactory defaultRenderersFactory)
-
getAllowHlsChunklessPreparation
boolean getAllowHlsChunklessPreparation()
-
setAllowHlsChunklessPreparation
void setAllowHlsChunklessPreparation(boolean allowHlsChunklessPreparation)
The value of this field in the HlsMediaSource defaults to true in ExoPlayer 2.17.0Override it here to false if your HLS delivery includes 608/708 captions
-
getUseDrmSessionsForClearContent
boolean getUseDrmSessionsForClearContent()
-
setUseDrmSessionsForClearContent
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)
-
isUsingBumper
Boolean isUsingBumper()
-
addListener
void addListener(ExoMediaPlayback.Listener listener)
-
removeListener
boolean removeListener(ExoMediaPlayback.Listener listener)
-
getExoPlayerDrmSessionManager
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 WIDEVINE_KEY_SYSTEM
-
getWidevineMediaDrmCallback
WidevineMediaDrmCallback getWidevineMediaDrmCallback()
-
onTaskRemoved
void onTaskRemoved(Intent rootIntent)
-
setPlaybackNotification
void setPlaybackNotification(PlaybackNotification playbackNotification)
-
getPlaybackNotification
static PlaybackNotification getPlaybackNotification()
Static method to access the notification
-
setVideoPath
Video setVideoPath(String path)
-
setVideoPath
Video setVideoPath(String videoPath, Map<String, String> languageCodeCaptionsMap)
-
add
void add(Video video)
-
add
void add(int index, Video video)
-
addAll
void addAll(Collection<Video> newVideos)
-
addAll
void addAll(int index, Collection<Video> newVideos)
-
getVideoAt
Video getVideoAt(int index)
-
remove
void remove(int index)
-
clear
void clear()
-
getBufferPercentage
int getBufferPercentage()
-
getVolume
float getVolume()
-
isSourceSet
boolean isSourceSet()
-
setNotificationConfig
void setNotificationConfig(PlaybackNotificationConfig config)
Configure the on-going notification.
- Parameters:
config
- The configuration to apply to the notification.
-
emitErrorEvent
void emitErrorEvent(String message)
-
emitErrorEvent
void emitErrorEvent(String message, Exception exception)
-
setEventEmitter
@RestrictTo(value = RestrictTo.Scope.LIBRARY) 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.
-
hasDvr
boolean hasDvr()
-
isLive
boolean isLive()
-
isInLiveEdge
boolean isInLiveEdge()
-
getCurrentPosition
long getCurrentPosition()
-
getPlayer
ExoPlayer getPlayer()
-
getLiveEdge
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).
-
getPlayerState
int getPlayerState()
Returns the ExoPlayer state if available,or -1 if the player is null.
-
setVideoSource
void setVideoSource(@Nullable() Video video, @Nullable() Source source)
Sets the video source that will be used for playback.
- Parameters:
video
- reference to the video, if any.source
- reference to the video source, if any.
-
isPlayingAudioOnly
boolean isPlayingAudioOnly()
-
openCurrentVideoSource
void openCurrentVideoSource()
-
isCurrentVideo360Mode
boolean isCurrentVideo360Mode()
-
useBumper
void useBumper(boolean useBumper)
-
didBumperPlay
boolean didBumperPlay()
-
bumperPlayed
void bumperPlayed(boolean bumperPlayed)
-
destroyPlayer
void destroyPlayer()
-
play
void play(long position)
Convenience method for easily starting the exoplayer.
-
pause
void pause()
Convenience method for easily pausing the exoplayer.
-
onHandlePlayPauseAction
@RestrictTo(value = RestrictTo.Scope.LIBRARY) void onHandlePlayPauseAction(int state)
Handle internal state and events for play/pause.
-
getDuration
long getDuration()
Returns the duration.
-
getPlaybackLooper
Looper getPlaybackLooper()
-
getVideoFormat
Format getVideoFormat()
-
getAudioFormat
Format getAudioFormat()
-
setVideoSelectionOverrideCreator
@Deprecated() void setVideoSelectionOverrideCreator(@NonNull() SelectionOverrideCreator creator)
Provides a creator for a DefaultTrackSelector.SelectionOverride instance specific forthe Video track.
This SelectionOverride is applied every time a new video is loaded, and when the setPeakBitrate is set.
-
setTrackSelectionOverrideCreator
void setTrackSelectionOverrideCreator(@NonNull() TrackSelectionOverrideCreator creator)
Provides a creator for a com.google.android.exoplayer2.trackselection.TrackSelectionOverride instance specific for the Video track.This TrackSelectionOverride is applied every time a new video is loaded, and when the setPeakBitrate is set.
If you want to disable the default TrackSelectionOverride, you may pass EMPTY, which returns EMPTY_TRACK_SELECTION_OVERRIDES and gets ignored when attempting to apply it to the DefaultTrackSelector.
-
replace
void replace(int index, Video video)
-
getBandwidthMeter
BandwidthMeter getBandwidthMeter()
Returns the current bandwidth meter. If null, a defaultbandwidth meter will be used.
-
setBandwidthMeter
void setBandwidthMeter(BandwidthMeter bandwidthMeter)
Sets the current bandwidth meter.
-
getDataSourceFactory
@NonNull() HttpDataSource.Factory getDataSourceFactory()
Returns the current HttpDataSource.Factory, which is used when creating the MediaSource.
-
setDataSourceFactory
void setDataSourceFactory(@NonNull() 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 defaultuser agent HTTP_USER_AGENT to avoid losing Brightcove Analyticsand Delivery Rules support.
- Parameters:
httpDataSourceFactory
- the http data source factory
-
getCurrentlyPlayingStreamType
PlaybackNotification.StreamType getCurrentlyPlayingStreamType()
-
-
-
-