public abstract class BasePlayer extends java.lang.Object implements Player
Player which implements common implementation independent methods.Player.AudioComponent, Player.DefaultEventListener, Player.DiscontinuityReason, Player.EventListener, Player.RepeatMode, Player.TextComponent, Player.TimelineChangeReason, Player.VideoComponent| Modifier and Type | Field and Description |
|---|---|
protected Timeline.Window |
window |
DISCONTINUITY_REASON_AD_INSERTION, DISCONTINUITY_REASON_INTERNAL, DISCONTINUITY_REASON_PERIOD_TRANSITION, DISCONTINUITY_REASON_SEEK, DISCONTINUITY_REASON_SEEK_ADJUSTMENT, REPEAT_MODE_ALL, REPEAT_MODE_OFF, REPEAT_MODE_ONE, STATE_BUFFERING, STATE_ENDED, STATE_IDLE, STATE_READY, TIMELINE_CHANGE_REASON_DYNAMIC, TIMELINE_CHANGE_REASON_PREPARED, TIMELINE_CHANGE_REASON_RESET| Constructor and Description |
|---|
BasePlayer() |
| Modifier and Type | Method and Description |
|---|---|
int |
getBufferedPercentage()
Returns an estimate of the percentage in the current content window or ad up to which data is
buffered, or 0 if no estimate is available.
|
long |
getContentDuration()
If
Player.isPlayingAd() returns true, returns the duration of the current content
window in milliseconds, or C.TIME_UNSET if the duration is not known. |
java.lang.Object |
getCurrentTag()
Returns the tag of the currently playing window in the timeline.
|
int |
getNextWindowIndex()
Returns the index of the next timeline window to be played, which may depend on the current
repeat mode and whether shuffle mode is enabled.
|
int |
getPreviousWindowIndex()
Returns the index of the previous timeline window to be played, which may depend on the current
repeat mode and whether shuffle mode is enabled.
|
boolean |
hasNext()
Returns whether a next window exists, which may depend on the current repeat mode and whether
shuffle mode is enabled.
|
boolean |
hasPrevious()
Returns whether a previous window exists, which may depend on the current repeat mode and
whether shuffle mode is enabled.
|
boolean |
isCurrentWindowDynamic()
Returns whether the current window is dynamic, or
false if the Timeline is
empty. |
boolean |
isCurrentWindowSeekable()
Returns whether the current window is seekable, or
false if the Timeline is
empty. |
void |
next()
Seeks to the default position of the next window in the timeline, which may depend on the
current repeat mode and whether shuffle mode is enabled.
|
void |
previous()
Seeks to the default position of the previous window in the timeline, which may depend on the
current repeat mode and whether shuffle mode is enabled.
|
void |
seekTo(long positionMs)
Seeks to a position specified in milliseconds in the current window.
|
void |
seekToDefaultPosition()
Seeks to the default position associated with the current window.
|
void |
seekToDefaultPosition(int windowIndex)
Seeks to the default position associated with the specified window.
|
void |
stop()
Stops playback without resetting the player.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddListener, getApplicationLooper, getAudioComponent, getBufferedPosition, getContentBufferedPosition, getContentPosition, getCurrentAdGroupIndex, getCurrentAdIndexInAdGroup, getCurrentManifest, getCurrentPeriodIndex, getCurrentPosition, getCurrentTimeline, getCurrentTrackGroups, getCurrentTrackSelections, getCurrentWindowIndex, getDuration, getPlaybackError, getPlaybackParameters, getPlaybackState, getPlayWhenReady, getRendererCount, getRendererType, getRepeatMode, getShuffleModeEnabled, getTextComponent, getTotalBufferedDuration, getVideoComponent, isLoading, isPlayingAd, release, removeListener, seekTo, setPlaybackParameters, setPlayWhenReady, setRepeatMode, setShuffleModeEnabled, stopprotected final Timeline.Window window
public final void seekToDefaultPosition()
PlayerseekToDefaultPosition in interface Playerpublic final void seekToDefaultPosition(int windowIndex)
PlayerseekToDefaultPosition in interface PlayerwindowIndex - The index of the window whose associated default position should be seeked
to.public final void seekTo(long positionMs)
PlayerseekTo in interface PlayerpositionMs - The seek position in the current window, or C.TIME_UNSET to seek to
the window's default position.public final boolean hasPrevious()
PlayerhasPrevious in interface Playerpublic final void previous()
PlayerPlayer.hasPrevious()
is false.public final boolean hasNext()
Playerpublic final void next()
PlayerPlayer.hasNext() is
false.public final void stop()
PlayersetPlayWhenReady(false) rather than
this method if the intention is to pause playback.
Calling this method will cause the playback state to transition to Player.STATE_IDLE. The
player instance can still be used, and Player.release() must still be called on the player if
it's no longer required.
Calling this method does not reset the playback position.
public final int getNextWindowIndex()
PlayerC.INDEX_UNSET if the window
currently being played is the last window.getNextWindowIndex in interface Playerpublic final int getPreviousWindowIndex()
PlayerC.INDEX_UNSET if the window
currently being played is the first window.getPreviousWindowIndex in interface Player@Nullable public final java.lang.Object getCurrentTag()
PlayergetCurrentTag in interface Playerpublic final int getBufferedPercentage()
PlayergetBufferedPercentage in interface Playerpublic final boolean isCurrentWindowDynamic()
Playerfalse if the Timeline is
empty.isCurrentWindowDynamic in interface PlayerTimeline.Window.isDynamicpublic final boolean isCurrentWindowSeekable()
Playerfalse if the Timeline is
empty.isCurrentWindowSeekable in interface PlayerTimeline.Window.isSeekablepublic final long getContentDuration()
PlayerPlayer.isPlayingAd() returns true, returns the duration of the current content
window in milliseconds, or C.TIME_UNSET if the duration is not known. If there is no ad
playing, the returned duration is the same as that returned by Player.getDuration().getContentDuration in interface Player