public abstract class StubExoPlayer extends BasePlayer implements ExoPlayer
ExoPlayer implementation that throws UnsupportedOperationException
from every method.ExoPlayer.BuilderPlayer.AudioComponent, Player.DefaultEventListener, Player.DeviceComponent, Player.DiscontinuityReason, Player.EventFlags, Player.EventListener, Player.Events, Player.MediaItemTransitionReason, Player.MetadataComponent, Player.PlaybackSuppressionReason, Player.PlayWhenReadyChangeReason, Player.RepeatMode, Player.State, Player.TextComponent, Player.TimelineChangeReason, Player.VideoComponentwindowDEFAULT_RELEASE_TIMEOUT_MSDISCONTINUITY_REASON_AD_INSERTION, DISCONTINUITY_REASON_INTERNAL, DISCONTINUITY_REASON_PERIOD_TRANSITION, DISCONTINUITY_REASON_SEEK, DISCONTINUITY_REASON_SEEK_ADJUSTMENT, EVENT_IS_LOADING_CHANGED, EVENT_IS_PLAYING_CHANGED, EVENT_MEDIA_ITEM_TRANSITION, EVENT_PLAY_WHEN_READY_CHANGED, EVENT_PLAYBACK_PARAMETERS_CHANGED, EVENT_PLAYBACK_STATE_CHANGED, EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED, EVENT_PLAYER_ERROR, EVENT_POSITION_DISCONTINUITY, EVENT_REPEAT_MODE_CHANGED, EVENT_SHUFFLE_MODE_ENABLED_CHANGED, EVENT_STATIC_METADATA_CHANGED, EVENT_TIMELINE_CHANGED, EVENT_TRACKS_CHANGED, MEDIA_ITEM_TRANSITION_REASON_AUTO, MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED, MEDIA_ITEM_TRANSITION_REASON_REPEAT, MEDIA_ITEM_TRANSITION_REASON_SEEK, PLAY_WHEN_READY_CHANGE_REASON_AUDIO_BECOMING_NOISY, PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS, PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM, PLAY_WHEN_READY_CHANGE_REASON_REMOTE, PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST, PLAYBACK_SUPPRESSION_REASON_NONE, PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS, REPEAT_MODE_ALL, REPEAT_MODE_OFF, REPEAT_MODE_ONE, STATE_BUFFERING, STATE_ENDED, STATE_IDLE, STATE_READY, TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, TIMELINE_CHANGE_REASON_SOURCE_UPDATE| Constructor | Description |
|---|---|
StubExoPlayer() |
| Modifier and Type | Method | Description |
|---|---|---|
void |
addListener(Player.EventListener listener) |
Register a listener to receive events from the player.
|
void |
addMediaItem(int index,
MediaItem mediaItem) |
Adds a media item at the given index of the playlist.
|
void |
addMediaItem(MediaItem mediaItem) |
Adds a media item to the end of the playlist.
|
void |
addMediaItems(int index,
List<MediaItem> mediaItems) |
Adds a list of media items at the given index of the playlist.
|
void |
addMediaItems(List<MediaItem> mediaItems) |
Adds a list of media items to the end of the playlist.
|
void |
addMediaSource(int index,
MediaSource mediaSource) |
Adds a media source at the given index of the playlist.
|
void |
addMediaSource(MediaSource mediaSource) |
Adds a media source to the end of the playlist.
|
void |
addMediaSources(int index,
List<MediaSource> mediaSources) |
Adds a list of media sources at the given index of the playlist.
|
void |
addMediaSources(List<MediaSource> mediaSources) |
Adds a list of media sources to the end of the playlist.
|
void |
clearMediaItems() |
Clears the playlist.
|
PlayerMessage |
createMessage(PlayerMessage.Target target) |
Creates a message that can be sent to a
PlayerMessage.Target. |
boolean |
experimentalIsSleepingForOffload() |
Returns whether the player has paused its main loop to save power in offload scheduling mode.
|
void |
experimentalSetOffloadSchedulingEnabled(boolean offloadSchedulingEnabled) |
Sets whether audio offload scheduling is enabled.
|
Looper |
getApplicationLooper() |
Returns the
Looper associated with the application thread that's used to access the
player and on which player events are received. |
Player.AudioComponent |
getAudioComponent() |
Returns the component of this player for audio output, or null if audio is not supported.
|
long |
getBufferedPosition() |
Returns an estimate of the position in the current content window or ad up to which data is
buffered, in milliseconds.
|
Clock |
getClock() |
Returns the
Clock used for playback. |
long |
getContentBufferedPosition() |
If
Player.isPlayingAd() returns true, returns an estimate of the content position in
the current content window up to which data is buffered, in milliseconds. |
long |
getContentPosition() |
If
Player.isPlayingAd() returns true, returns the content position that will be
played once all ads in the ad group have finished playing, in milliseconds. |
int |
getCurrentAdGroupIndex() |
If
Player.isPlayingAd() returns true, returns the index of the ad group in the period
currently being played. |
int |
getCurrentAdIndexInAdGroup() |
If
Player.isPlayingAd() returns true, returns the index of the ad in its ad group. |
int |
getCurrentPeriodIndex() |
Returns the index of the period currently being played.
|
long |
getCurrentPosition() |
Returns the playback position in the current content window or ad, in milliseconds, or the
prospective position in milliseconds if the
current timeline is
empty. |
List<Metadata> |
getCurrentStaticMetadata() |
Returns the current static metadata for the track selections.
|
Timeline |
getCurrentTimeline() |
Returns the current
Timeline. |
TrackGroupArray |
getCurrentTrackGroups() |
Returns the available track groups.
|
TrackSelectionArray |
getCurrentTrackSelections() |
Returns the current track selections for each renderer.
|
int |
getCurrentWindowIndex() |
Returns the index of the current
window in the timeline, or the prospective window index if the current timeline is empty. |
Player.DeviceComponent |
getDeviceComponent() |
Returns the component of this player for playback device, or null if it's not supported.
|
long |
getDuration() |
Returns the duration of the current content window or ad in milliseconds, or
C.TIME_UNSET if the duration is not known. |
Player.MetadataComponent |
getMetadataComponent() |
Returns the component of this player for metadata output, or null if metadata is not supported.
|
boolean |
getPauseAtEndOfMediaItems() |
Returns whether the player pauses playback at the end of each media item.
|
ExoPlaybackException |
getPlaybackError() |
Deprecated.
Use
getPlayerError() instead. |
Looper |
getPlaybackLooper() |
Returns the
Looper associated with the playback thread. |
PlaybackParameters |
getPlaybackParameters() |
Returns the currently active playback parameters.
|
int |
getPlaybackState() |
Returns the current
playback state of the player. |
int |
getPlaybackSuppressionReason() |
Returns the reason why playback is suppressed even though
Player.getPlayWhenReady() is
true, or Player.PLAYBACK_SUPPRESSION_REASON_NONE if playback is not suppressed. |
ExoPlaybackException |
getPlayerError() |
Returns the error that caused playback to fail.
|
boolean |
getPlayWhenReady() |
Whether playback will proceed when
Player.getPlaybackState() == Player.STATE_READY. |
int |
getRendererCount() |
Returns the number of renderers.
|
int |
getRendererType(int index) |
Returns the track type that the renderer at a given index handles.
|
int |
getRepeatMode() |
Returns the current
Player.RepeatMode used for playback. |
SeekParameters |
getSeekParameters() |
Returns the currently active
SeekParameters of the player. |
boolean |
getShuffleModeEnabled() |
Returns whether shuffling of windows is enabled.
|
Player.TextComponent |
getTextComponent() |
Returns the component of this player for text output, or null if text is not supported.
|
long |
getTotalBufferedDuration() |
Returns an estimate of the total buffered duration from the current position, in milliseconds.
|
TrackSelector |
getTrackSelector() |
Returns the track selector that this player uses, or null if track selection is not supported.
|
Player.VideoComponent |
getVideoComponent() |
Returns the component of this player for video output, or null if video is not supported.
|
boolean |
isLoading() |
Whether the player is currently loading the source.
|
boolean |
isPlayingAd() |
Returns whether the player is currently playing an ad.
|
void |
moveMediaItem(int currentIndex,
int newIndex) |
Moves the media item at the current index to the new index.
|
void |
moveMediaItems(int fromIndex,
int toIndex,
int newIndex) |
Moves the media item range to the new index.
|
void |
prepare() |
Deprecated.
Use
setMediaSource(MediaSource) and Player.prepare() instead. |
void |
prepare(MediaSource mediaSource) |
Deprecated.
Use
setMediaSource(MediaSource) and Player.prepare() instead. |
void |
prepare(MediaSource mediaSource,
boolean resetPosition,
boolean resetState) |
Deprecated.
Use
setMediaSource(MediaSource, boolean) and Player.prepare()
instead. |
void |
release() |
Releases the player.
|
void |
removeListener(Player.EventListener listener) |
Unregister a listener.
|
void |
removeMediaItem(int index) |
Removes the media item at the given index of the playlist.
|
void |
removeMediaItems(int fromIndex,
int toIndex) |
Removes a range of media items from the playlist.
|
void |
retry() |
Deprecated.
Use
prepare() instead. |
void |
seekTo(int windowIndex,
long positionMs) |
Seeks to a position specified in milliseconds in the specified window.
|
void |
setForegroundMode(boolean foregroundMode) |
Sets whether the player is allowed to keep holding limited resources such as video decoders,
even when in the idle state.
|
void |
setMediaItem(MediaItem mediaItem) |
Clears the playlist, adds the specified
MediaItem and resets the position to the
default position. |
void |
setMediaItem(MediaItem mediaItem,
boolean resetPosition) |
Clears the playlist and adds the specified
MediaItem. |
void |
setMediaItem(MediaItem mediaItem,
long startPositionMs) |
Clears the playlist and adds the specified
MediaItem. |
void |
setMediaItems(List<MediaItem> mediaItems) |
Clears the playlist, adds the specified
MediaItems and resets the position to
the default position. |
void |
setMediaItems(List<MediaItem> mediaItems,
boolean resetPosition) |
Clears the playlist and adds the specified
MediaItems. |
void |
setMediaItems(List<MediaItem> mediaItems,
int startWindowIndex,
long startPositionMs) |
Clears the playlist and adds the specified
MediaItems. |
void |
setMediaSource(MediaSource mediaSource) |
Clears the playlist, adds the specified
MediaSource and resets the position to the
default position. |
void |
setMediaSource(MediaSource mediaSource,
boolean resetPosition) |
Clears the playlist and adds the specified
MediaSource. |
void |
setMediaSource(MediaSource mediaSource,
long startPositionMs) |
Clears the playlist and adds the specified
MediaSource. |
void |
setMediaSources(List<MediaSource> mediaSources) |
Clears the playlist, adds the specified
MediaSources and resets the
position to the default position. |
void |
setMediaSources(List<MediaSource> mediaSources,
boolean resetPosition) |
Clears the playlist and adds the specified
MediaSources. |
void |
setMediaSources(List<MediaSource> mediaSources,
int startWindowIndex,
long startPositionMs) |
Clears the playlist and adds the specified
MediaSources. |
void |
setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems) |
Sets whether to pause playback at the end of each media item.
|
void |
setPlaybackParameters(PlaybackParameters playbackParameters) |
Attempts to set the playback parameters.
|
void |
setPlayWhenReady(boolean playWhenReady) |
Sets whether playback should proceed when
Player.getPlaybackState() == Player.STATE_READY. |
void |
setRepeatMode(int repeatMode) |
Sets the
Player.RepeatMode to be used for playback. |
void |
setSeekParameters(SeekParameters seekParameters) |
Sets the parameters that control how seek operations are performed.
|
void |
setShuffleModeEnabled(boolean shuffleModeEnabled) |
Sets whether shuffling of windows is enabled.
|
void |
setShuffleOrder(ShuffleOrder shuffleOrder) |
Sets the shuffle order.
|
void |
stop(boolean reset) |
getBufferedPercentage, getContentDuration, getCurrentLiveOffset, getCurrentManifest, getCurrentMediaItem, getCurrentTag, getMediaItemAt, getMediaItemCount, getNextWindowIndex, getPreviousWindowIndex, hasNext, hasPrevious, isCurrentWindowDynamic, isCurrentWindowLive, isCurrentWindowSeekable, isPlaying, next, pause, play, previous, seekTo, seekToDefaultPosition, seekToDefaultPosition, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBufferedPercentage, getContentDuration, getCurrentLiveOffset, getCurrentManifest, getCurrentMediaItem, getCurrentTag, getMediaItemAt, getMediaItemCount, getNextWindowIndex, getPreviousWindowIndex, hasNext, hasPrevious, isCurrentWindowDynamic, isCurrentWindowLive, isCurrentWindowSeekable, isPlaying, next, pause, play, previous, seekTo, seekToDefaultPosition, seekToDefaultPosition, stoppublic Player.AudioComponent getAudioComponent()
PlayergetAudioComponent in interface Playerpublic Player.VideoComponent getVideoComponent()
PlayergetVideoComponent in interface Playerpublic Player.TextComponent getTextComponent()
PlayergetTextComponent in interface Playerpublic Player.MetadataComponent getMetadataComponent()
PlayergetMetadataComponent in interface Playerpublic Player.DeviceComponent getDeviceComponent()
PlayergetDeviceComponent in interface Playerpublic Looper getPlaybackLooper()
ExoPlayerLooper associated with the playback thread.getPlaybackLooper in interface ExoPlayerpublic Looper getApplicationLooper()
PlayerLooper associated with the application thread that's used to access the
player and on which player events are received.getApplicationLooper in interface Playerpublic Clock getClock()
ExoPlayerClock used for playback.public void addListener(Player.EventListener listener)
PlayerLooper, then the listener will be called on the main thread.addListener in interface Playerlistener - The listener to register.public void removeListener(Player.EventListener listener)
PlayerremoveListener in interface Playerlistener - The listener to unregister.@State public int getPlaybackState()
Playerplayback state of the player.getPlaybackState in interface Playerplayback state.Player.EventListener.onPlaybackStateChanged(int)@PlaybackSuppressionReason public int getPlaybackSuppressionReason()
PlayerPlayer.getPlayWhenReady() is
true, or Player.PLAYBACK_SUPPRESSION_REASON_NONE if playback is not suppressed.getPlaybackSuppressionReason in interface Playerplayback suppression reason.Player.EventListener.onPlaybackSuppressionReasonChanged(int)@Deprecated public ExoPlaybackException getPlaybackError()
getPlayerError() instead.getPlaybackError in interface Playerpublic ExoPlaybackException getPlayerError()
PlayerPlayer.EventListener.onPlayerError(ExoPlaybackException) at the time of
failure. It can be queried using this method until the player is re-prepared.
Note that this method will always return null if Player.getPlaybackState() is not
Player.STATE_IDLE.
getPlayerError in interface Playernull.Player.EventListener.onPlayerError(ExoPlaybackException)@Deprecated public void retry()
prepare() instead.@Deprecated public void prepare()
setMediaSource(MediaSource) and Player.prepare() instead.Player@Deprecated public void prepare(MediaSource mediaSource)
setMediaSource(MediaSource) and Player.prepare() instead.@Deprecated public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState)
setMediaSource(MediaSource, boolean) and Player.prepare()
instead.public void setMediaItem(MediaItem mediaItem)
PlayerMediaItem and resets the position to the
default position.setMediaItem in interface PlayersetMediaItem in class BasePlayermediaItem - The new MediaItem.public void setMediaItem(MediaItem mediaItem, long startPositionMs)
PlayerMediaItem.setMediaItem in interface PlayersetMediaItem in class BasePlayermediaItem - The new MediaItem.startPositionMs - The position in milliseconds to start playback from.public void setMediaItem(MediaItem mediaItem, boolean resetPosition)
PlayerMediaItem.setMediaItem in interface PlayersetMediaItem in class BasePlayermediaItem - The new MediaItem.resetPosition - Whether the playback position should be reset to the default position. If
false, playback will start from the position defined by Player.getCurrentWindowIndex()
and Player.getCurrentPosition().public void setMediaItems(List<MediaItem> mediaItems)
PlayerMediaItems and resets the position to
the default position.setMediaItems in interface PlayersetMediaItems in class BasePlayermediaItems - The new MediaItems.public void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition)
PlayerMediaItems.setMediaItems in interface PlayermediaItems - The new MediaItems.resetPosition - Whether the playback position should be reset to the default position in
the first Timeline.Window. If false, playback will start from the position defined
by Player.getCurrentWindowIndex() and Player.getCurrentPosition().public void setMediaItems(List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs)
PlayerMediaItems.setMediaItems in interface PlayermediaItems - The new MediaItems.startWindowIndex - The window index to start playback from. If C.INDEX_UNSET is
passed, the current position is not reset.startPositionMs - The position in milliseconds to start playback from. If C.TIME_UNSET is passed, the default position of the given window is used. In any case, if
startWindowIndex is set to C.INDEX_UNSET, this parameter is ignored and the
position is not reset at all.public void setMediaSource(MediaSource mediaSource)
ExoPlayerMediaSource and resets the position to the
default position.setMediaSource in interface ExoPlayermediaSource - The new MediaSource.public void setMediaSource(MediaSource mediaSource, long startPositionMs)
ExoPlayerMediaSource.setMediaSource in interface ExoPlayermediaSource - The new MediaSource.startPositionMs - The position in milliseconds to start playback from.public void setMediaSource(MediaSource mediaSource, boolean resetPosition)
ExoPlayerMediaSource.setMediaSource in interface ExoPlayermediaSource - The new MediaSource.resetPosition - Whether the playback position should be reset to the default position. If
false, playback will start from the position defined by Player.getCurrentWindowIndex()
and Player.getCurrentPosition().public void setMediaSources(List<MediaSource> mediaSources)
ExoPlayerMediaSources and resets the
position to the default position.setMediaSources in interface ExoPlayermediaSources - The new MediaSources.public void setMediaSources(List<MediaSource> mediaSources, boolean resetPosition)
ExoPlayerMediaSources.setMediaSources in interface ExoPlayermediaSources - The new MediaSources.resetPosition - Whether the playback position should be reset to the default position in
the first Timeline.Window. If false, playback will start from the position defined
by Player.getCurrentWindowIndex() and Player.getCurrentPosition().public void setMediaSources(List<MediaSource> mediaSources, int startWindowIndex, long startPositionMs)
ExoPlayerMediaSources.setMediaSources in interface ExoPlayermediaSources - The new MediaSources.startWindowIndex - The window index to start playback from. If C.INDEX_UNSET is
passed, the current position is not reset.startPositionMs - The position in milliseconds to start playback from. If C.TIME_UNSET is passed, the default position of the given window is used. In any case, if
startWindowIndex is set to C.INDEX_UNSET, this parameter is ignored and the
position is not reset at all.public void addMediaItem(MediaItem mediaItem)
PlayeraddMediaItem in interface PlayeraddMediaItem in class BasePlayermediaItem - The MediaItem to add.public void addMediaItem(int index,
MediaItem mediaItem)
PlayeraddMediaItem in interface PlayeraddMediaItem in class BasePlayerindex - The index at which to add the item.mediaItem - The MediaItem to add.public void addMediaItems(List<MediaItem> mediaItems)
PlayeraddMediaItems in interface PlayermediaItems - The MediaItems to add.public void addMediaItems(int index,
List<MediaItem> mediaItems)
PlayeraddMediaItems in interface Playerindex - The index at which to add the media items.mediaItems - The MediaItems to add.public void addMediaSource(MediaSource mediaSource)
ExoPlayeraddMediaSource in interface ExoPlayermediaSource - The MediaSource to add.public void addMediaSource(int index,
MediaSource mediaSource)
ExoPlayeraddMediaSource in interface ExoPlayerindex - The index at which to add the source.mediaSource - The MediaSource to add.public void addMediaSources(List<MediaSource> mediaSources)
ExoPlayeraddMediaSources in interface ExoPlayermediaSources - The MediaSources to add.public void addMediaSources(int index,
List<MediaSource> mediaSources)
ExoPlayeraddMediaSources in interface ExoPlayerindex - The index at which to add the media sources.mediaSources - The MediaSources to add.public void moveMediaItem(int currentIndex,
int newIndex)
PlayermoveMediaItem in interface PlayermoveMediaItem in class BasePlayercurrentIndex - The current index of the media item to move.newIndex - The new index of the media item. If the new index is larger than the size of
the playlist the item is moved to the end of the playlist.public void moveMediaItems(int fromIndex,
int toIndex,
int newIndex)
PlayermoveMediaItems in interface PlayerfromIndex - The start of the range to move.toIndex - The first item not to be included in the range (exclusive).newIndex - The new index of the first media item of the range. If the new index is larger
than the size of the remaining playlist after removing the range, the range is moved to the
end of the playlist.public void removeMediaItem(int index)
PlayerremoveMediaItem in interface PlayerremoveMediaItem in class BasePlayerindex - The index at which to remove the media item.public void removeMediaItems(int fromIndex,
int toIndex)
PlayerremoveMediaItems in interface PlayerfromIndex - The index at which to start removing media items.toIndex - The index of the first item to be kept (exclusive).public void clearMediaItems()
PlayerclearMediaItems in interface Playerpublic void setPlayWhenReady(boolean playWhenReady)
PlayerPlayer.getPlaybackState() == Player.STATE_READY.
If the player is already in the ready state then this method pauses and resumes playback.
setPlayWhenReady in interface PlayerplayWhenReady - Whether playback should proceed when ready.public boolean getPlayWhenReady()
PlayerPlayer.getPlaybackState() == Player.STATE_READY.getPlayWhenReady in interface PlayerPlayer.EventListener.onPlayWhenReadyChanged(boolean, int)public void setRepeatMode(@RepeatMode int repeatMode)
PlayerPlayer.RepeatMode to be used for playback.setRepeatMode in interface PlayerrepeatMode - The repeat mode.public int getRepeatMode()
PlayerPlayer.RepeatMode used for playback.getRepeatMode in interface PlayerPlayer.EventListener.onRepeatModeChanged(int)public void setShuffleOrder(ShuffleOrder shuffleOrder)
ExoPlayersetShuffleOrder in interface ExoPlayershuffleOrder - The shuffle order.public void setShuffleModeEnabled(boolean shuffleModeEnabled)
PlayersetShuffleModeEnabled in interface PlayershuffleModeEnabled - Whether shuffling is enabled.public boolean getShuffleModeEnabled()
PlayergetShuffleModeEnabled in interface PlayerPlayer.EventListener.onShuffleModeEnabledChanged(boolean)public boolean isLoading()
PlayerisLoading in interface PlayerPlayer.EventListener.onIsLoadingChanged(boolean)public void seekTo(int windowIndex,
long positionMs)
PlayerseekTo in interface PlayerwindowIndex - The index of the window.positionMs - The seek position in the specified window, or C.TIME_UNSET to seek to
the window's default position.public void setPlaybackParameters(@Nullable
PlaybackParameters playbackParameters)
Playernull sets the parameters to the
default, PlaybackParameters.DEFAULT, which means there is no speed or pitch adjustment.
Playback parameters changes may cause the player to buffer. Player.EventListener.onPlaybackParametersChanged(PlaybackParameters) will be called whenever the
currently active playback parameters change.
setPlaybackParameters in interface PlayerplaybackParameters - The playback parameters, or null to use the defaults.public PlaybackParameters getPlaybackParameters()
PlayergetPlaybackParameters in interface PlayerPlayer.EventListener.onPlaybackParametersChanged(PlaybackParameters)public void setSeekParameters(@Nullable
SeekParameters seekParameters)
ExoPlayersetSeekParameters in interface ExoPlayerseekParameters - The seek parameters, or null to use the defaults.public SeekParameters getSeekParameters()
ExoPlayerSeekParameters of the player.getSeekParameters in interface ExoPlayerpublic void release()
Playerpublic PlayerMessage createMessage(PlayerMessage.Target target)
ExoPlayerPlayerMessage.Target. By default, the message
will be delivered immediately without blocking on the playback thread. The default PlayerMessage.getType() is 0 and the default PlayerMessage.getPayload() is null. If a
position is specified with PlayerMessage.setPosition(long), the message will be
delivered at this position in the current window defined by Player.getCurrentWindowIndex().
Alternatively, the message can be sent at a specific window using PlayerMessage.setPosition(int, long).createMessage in interface ExoPlayerpublic int getRendererCount()
PlayergetRendererCount in interface Playerpublic int getRendererType(int index)
PlayerFor example, a video renderer will return C.TRACK_TYPE_VIDEO, an audio renderer will
return C.TRACK_TYPE_AUDIO and a text renderer will return C.TRACK_TYPE_TEXT.
getRendererType in interface Playerindex - The index of the renderer.TRACK_TYPE_* constants defined in C.@Nullable public TrackSelector getTrackSelector()
ExoPlayergetTrackSelector in interface ExoPlayerpublic TrackGroupArray getCurrentTrackGroups()
PlayergetCurrentTrackGroups in interface PlayerPlayer.EventListener.onTracksChanged(TrackGroupArray, TrackSelectionArray)public TrackSelectionArray getCurrentTrackSelections()
PlayerA concrete implementation may include null elements if it has a fixed number of renderer components, wishes to report a TrackSelection for each of them, and has one or more renderer components that is not assigned any selected tracks.
getCurrentTrackSelections in interface Playerpublic List<Metadata> getCurrentStaticMetadata()
PlayerThe returned metadataList is an immutable list of Metadata instances, where
the elements correspond to the current track selections,
or an empty list if there are no track selections or the selected tracks contain no static
metadata.
This metadata is considered static in that it comes from the tracks' declared Formats, rather than being timed (or dynamic) metadata, which is represented within a metadata track.
getCurrentStaticMetadata in interface PlayerPlayer.EventListener.onStaticMetadataChanged(List)public Timeline getCurrentTimeline()
PlayerTimeline. Never null, but may be empty.getCurrentTimeline in interface PlayerPlayer.EventListener.onTimelineChanged(Timeline, int)public int getCurrentPeriodIndex()
PlayergetCurrentPeriodIndex in interface Playerpublic int getCurrentWindowIndex()
Playerwindow in the timeline, or the prospective window index if the current timeline is empty.getCurrentWindowIndex in interface Playerpublic long getDuration()
PlayerC.TIME_UNSET if the duration is not known.getDuration in interface Playerpublic long getCurrentPosition()
Playercurrent timeline is
empty.getCurrentPosition in interface Playerpublic long getBufferedPosition()
PlayergetBufferedPosition in interface Playerpublic long getTotalBufferedDuration()
PlayergetTotalBufferedDuration in interface Playerpublic boolean isPlayingAd()
PlayerisPlayingAd in interface Playerpublic int getCurrentAdGroupIndex()
PlayerPlayer.isPlayingAd() returns true, returns the index of the ad group in the period
currently being played. Returns C.INDEX_UNSET otherwise.getCurrentAdGroupIndex in interface Playerpublic int getCurrentAdIndexInAdGroup()
PlayerPlayer.isPlayingAd() returns true, returns the index of the ad in its ad group. Returns
C.INDEX_UNSET otherwise.getCurrentAdIndexInAdGroup in interface Playerpublic long getContentPosition()
PlayerPlayer.isPlayingAd() returns true, returns the content position that will be
played once all ads in the ad group have finished playing, in milliseconds. If there is no ad
playing, the returned position is the same as that returned by Player.getCurrentPosition().getContentPosition in interface Playerpublic long getContentBufferedPosition()
PlayerPlayer.isPlayingAd() returns true, returns an estimate of the content position in
the current content window up to which data is buffered, in milliseconds. If there is no ad
playing, the returned position is the same as that returned by Player.getBufferedPosition().getContentBufferedPosition in interface Playerpublic void setForegroundMode(boolean foregroundMode)
ExoPlayerThis mode should be used with caution, since holding limited resources may prevent other players of media components from acquiring them. It should only be enabled when both of the following conditions are true:
Player.stop() is called to halt one playback, and
ExoPlayer.prepare(com.google.android.exoplayer2.source.MediaSource) is called some time later to start a new one).
Note that foreground mode is not useful for switching between content without gaps
between the playbacks. For this use case Player.stop() does not need to be called, and simply
calling ExoPlayer.prepare(com.google.android.exoplayer2.source.MediaSource) for the new media will cause limited resources to be retained even if
foreground mode is not enabled.
If foreground mode is enabled, it's the application's responsibility to disable it when the conditions described above no longer hold.
setForegroundMode in interface ExoPlayerforegroundMode - Whether the player is allowed to keep limited resources even when in the
idle state.public void setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems)
ExoPlayerThis means the player will pause at the end of each window in the current timeline. Listeners will be informed by a call to Player.EventListener.onPlayWhenReadyChanged(boolean, int) with the reason Player.PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM when this happens.
setPauseAtEndOfMediaItems in interface ExoPlayerpauseAtEndOfMediaItems - Whether to pause playback at the end of each media item.public boolean getPauseAtEndOfMediaItems()
ExoPlayergetPauseAtEndOfMediaItems in interface ExoPlayerExoPlayer.setPauseAtEndOfMediaItems(boolean)public void experimentalSetOffloadSchedulingEnabled(boolean offloadSchedulingEnabled)
ExoPlayerOnly use this scheduling mode if the player is not displaying anything to the user. For example when the application is in the background, or the screen is off. The player state (including position) is rarely updated (roughly between every 10 seconds and 1 minute).
While offload scheduling is enabled, player events may be delivered severely delayed and
apps should not interact with the player. When returning to the foreground, disable offload
scheduling and wait for Player.EventListener.onExperimentalOffloadSchedulingEnabledChanged(boolean) to be called with
offloadSchedulingEnabled = false before interacting with the player.
This mode should save significant power when the phone is playing offload audio with the screen off.
This mode only has an effect when playing an audio track in offload mode, which requires all the following:
DefaultRenderersFactory.setEnableAudioOffload(boolean) or the equivalent option passed to DefaultAudioSink(AudioCapabilities,
DefaultAudioSink.AudioProcessorChain, boolean, boolean, boolean).
AudioSink is playing with an offload AudioTrack.
The state where ExoPlayer main loop has been paused to save power during offload playback
can be queried with ExoPlayer.experimentalIsSleepingForOffload().
This method is experimental, and will be renamed or removed in a future release.
experimentalSetOffloadSchedulingEnabled in interface ExoPlayeroffloadSchedulingEnabled - Whether to enable offload scheduling.public boolean experimentalIsSleepingForOffload()
ExoPlayer