Interface Player
-
- All Known Subinterfaces:
ExoPlayer
- All Known Implementing Classes:
BasePlayer
,CastPlayer
,ForwardingPlayer
,SimpleBasePlayer
,SimpleExoPlayer
,StubExoPlayer
,StubPlayer
@Deprecated public interface Player
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.A media player interface defining high-level functionality, such as the ability to play, pause, seek and query properties of the currently playing media.Player features and usage
Some important properties of media players that implement this interface are:
- All methods must be called from a single application thread unless indicated otherwise. Callbacks in registered listeners are called on the same thread.
- The available functionality can be limited. Player instances provide a set of
availabe commands
to signal feature support and users of the interface must only call methods if the correspondingPlayer.Command
is available. - Users can register
Player.Listener
callbacks that get informed about state changes. - Player instances need to update the visible state immediately after each method call, even if the actual changes are handled on background threads or even other devices. This simplifies the usage for callers of methods as no asynchronous handling needs to be considered.
- Player instances can provide playlist operations, like 'set', 'add', 'remove', 'move' or
'replace' of
MediaItem
instances. The player can also support repeat modes and shuffling within this playlist. The player provides aTimeline
representing the structure of the playlist and all its items, which can be obtained by callinggetCurrentTimeline()
- Player instances can provide seeking within the currently playing item and to other items,
using the various
seek...
methods. - Player instances can provide
Tracks
defining the currently available and selected tracks, which can be obtained by callinggetCurrentTracks()
. Users can also modify track selection behavior by settingTrackSelectionParameters
withsetTrackSelectionParameters(com.google.android.exoplayer2.trackselection.TrackSelectionParameters)
. - Player instances can provide
MediaMetadata
about the currently playing item, which can be obtained by callinggetMediaMetadata()
. - Player instances can provide information about ads in its media structure, for example via
isPlayingAd()
. - Player instances can accept different types of video outputs, like
SurfaceView
orTextureView
for video rendering. - Player instances can handle playback speed, audio attributes, and audio volume.
- Player instances can provide information about the playback device, which may be remote, and allow to change the device's volume.
API stability guarantees
The majority of the Player interface and its related classes are part of the stable API that guarantees backwards-compatibility for users of the API. Only more advances use cases may need to rely on
UnstableApi
classes and methods that are subject to incompatible changes or even removal in a future release. Implementors of the Player interface are not covered by these API stability guarantees.Player state
Users can listen to state changes by adding a
Player.Listener
withaddListener(com.google.android.exoplayer2.Player.Listener)
.The main elements of the overall player state are:
- Playlist
MediaItem
instances can be added with methods likesetMediaItem(com.google.android.exoplayer2.MediaItem)
to define what the player will be playing.- The current playlist can be obtained via
getCurrentTimeline()
and convenience methods likegetMediaItemCount()
orgetCurrentMediaItem()
. - With an empty playlist, the player can only be in
STATE_IDLE
orSTATE_ENDED
.
- Playback state
STATE_IDLE
: This is the initial state, the state when the player is stopped, and when playback failed. The player will hold only limited resources in this state.prepare()
must be called to transition away from this state.STATE_BUFFERING
: The player is not able to immediately play from its current position. This mostly happens because more data needs to be loaded.STATE_READY
: The player is able to immediately play from its current position.STATE_ENDED
: The player finished playing all media, or there is no media to play.
- Play/Pause, playback suppression and isPlaying
- playWhenReady: Indicates the user intention to play.
It can be set with
play()
orpause()
. - playback suppression: Defines a reason
for which playback will be suppressed even if playWhenReady is
true
. isPlaying()
: Whether the player is playing (that is, its position is advancing and media is being presented). This will only betrue
if playback state isSTATE_READY
, playWhenReady istrue
, and playback is not suppressed.
- playWhenReady: Indicates the user intention to play.
It can be set with
- Playback position
- media item index: The index in the playlist.
- ad insertion: Whether an inserted ad is playing and which ad group index and ad index in the group it belongs to
- current position: The current position of the playback. This is the same as the content position unless an ad is playing, where this indicates the position in the inserted ad.
Note that there are no callbacks for normal playback progression, only for transitions between media items and other position discontinuities. Code that needs to monitor playback progress (for example, an UI progress bar) should query the current position in appropriate intervals.
Implementing the Player interface
Implementing the Player interface is complex, as the interface includes many convenience methods that need to provide a consistent state and behavior, requires correct handling of listeners and available commands, and expects immediate state changes even if methods are internally handled asynchronously. For this reason, implementations are advised to inherit
SimpleBasePlayer
that handles all of these complexities and provides a simpler integration point for implementors of the interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Player.Command
Deprecated.Commands that indicate which method calls are currently permitted on a particularPlayer
instance.static class
Player.Commands
Deprecated.A set of commands.static interface
Player.DiscontinuityReason
Deprecated.Reasons for position discontinuities.static interface
Player.Event
Deprecated.Events that can be reported viaPlayer.Listener.onEvents(Player, Events)
.static class
Player.Events
Deprecated.A set of events.static interface
Player.Listener
Deprecated.Listener for changes in aPlayer
.static interface
Player.MediaItemTransitionReason
Deprecated.Reasons for media item transitions.static interface
Player.PlaybackSuppressionReason
Deprecated.Reason why playback is suppressed even thoughgetPlayWhenReady()
istrue
.static interface
Player.PlayWhenReadyChangeReason
Deprecated.Reasons forplayWhenReady
changes.static class
Player.PositionInfo
Deprecated.Position info describing a playback position involved in a discontinuity.static interface
Player.RepeatMode
Deprecated.Repeat modes for playback.static interface
Player.State
Deprecated.Playback state.static interface
Player.TimelineChangeReason
Deprecated.Reasons for timeline changes.
-
Field Summary
Fields Modifier and Type Field Description static int
COMMAND_ADJUST_DEVICE_VOLUME
Deprecated.UseCOMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS
instead.static int
COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS
Deprecated.Command to increase and decrease the device volume and mute it with volume flags.static int
COMMAND_CHANGE_MEDIA_ITEMS
Deprecated.Command to change the media items in the playlist.static int
COMMAND_GET_AUDIO_ATTRIBUTES
Deprecated.Command to get the player currentAudioAttributes
.static int
COMMAND_GET_CURRENT_MEDIA_ITEM
Deprecated.Command to get information about the currently playingMediaItem
.static int
COMMAND_GET_DEVICE_VOLUME
Deprecated.Command to get the device volume and whether it is muted.static int
COMMAND_GET_MEDIA_ITEMS_METADATA
Deprecated.UseCOMMAND_GET_METADATA
instead.static int
COMMAND_GET_METADATA
Deprecated.Command to get metadata related to the playlist and currentMediaItem
.static int
COMMAND_GET_TEXT
Deprecated.Command to get the text that should currently be displayed by the player.static int
COMMAND_GET_TIMELINE
Deprecated.Command to get the information about the current timeline.static int
COMMAND_GET_TRACKS
Deprecated.Command to get details of the current track selection.static int
COMMAND_GET_VOLUME
Deprecated.Command to get the player volume.static int
COMMAND_INVALID
Deprecated.Represents an invalidPlayer.Command
.static int
COMMAND_PLAY_PAUSE
Deprecated.Command to start, pause or resume playback.static int
COMMAND_PREPARE
Deprecated.Command to prepare the player.static int
COMMAND_RELEASE
Deprecated.Command to release the player.static int
COMMAND_SEEK_BACK
Deprecated.Command to seek back by a fixed increment inside the currentMediaItem
.static int
COMMAND_SEEK_FORWARD
Deprecated.Command to seek forward by a fixed increment inside the currentMediaItem
.static int
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
Deprecated.Command to seek anywhere inside the currentMediaItem
.static int
COMMAND_SEEK_IN_CURRENT_WINDOW
Deprecated.UseCOMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
instead.static int
COMMAND_SEEK_TO_DEFAULT_POSITION
Deprecated.Command to seek to the default position of the currentMediaItem
.static int
COMMAND_SEEK_TO_MEDIA_ITEM
Deprecated.Command to seek anywhere in anyMediaItem
.static int
COMMAND_SEEK_TO_NEXT
Deprecated.static int
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
Deprecated.Command to seek to the default position of the nextMediaItem
.static int
COMMAND_SEEK_TO_NEXT_WINDOW
Deprecated.UseCOMMAND_SEEK_TO_NEXT_MEDIA_ITEM
instead.static int
COMMAND_SEEK_TO_PREVIOUS
Deprecated.static int
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
Deprecated.Command to seek to the default position of the previousMediaItem
.static int
COMMAND_SEEK_TO_PREVIOUS_WINDOW
Deprecated.UseCOMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
instead.static int
COMMAND_SEEK_TO_WINDOW
Deprecated.UseCOMMAND_SEEK_TO_MEDIA_ITEM
instead.static int
COMMAND_SET_DEVICE_VOLUME
Deprecated.UseCOMMAND_SET_DEVICE_VOLUME_WITH_FLAGS
instead.static int
COMMAND_SET_DEVICE_VOLUME_WITH_FLAGS
Deprecated.Command to set the device volume with volume flags.static int
COMMAND_SET_MEDIA_ITEM
Deprecated.Command to set aMediaItem
.static int
COMMAND_SET_MEDIA_ITEMS_METADATA
Deprecated.UseCOMMAND_SET_PLAYLIST_METADATA
instead.static int
COMMAND_SET_PLAYLIST_METADATA
Deprecated.Command to set the playlist metadata.static int
COMMAND_SET_REPEAT_MODE
Deprecated.Command to set the repeat mode.static int
COMMAND_SET_SHUFFLE_MODE
Deprecated.Command to enable shuffling.static int
COMMAND_SET_SPEED_AND_PITCH
Deprecated.Command to set the playback speed and pitch.static int
COMMAND_SET_TRACK_SELECTION_PARAMETERS
Deprecated.Command to set the player's track selection parameters.static int
COMMAND_SET_VIDEO_SURFACE
Deprecated.Command to set and clear the surface on which to render the video.static int
COMMAND_SET_VOLUME
Deprecated.Command to set the player volume.static int
COMMAND_STOP
Deprecated.Command to stop playback.static int
DISCONTINUITY_REASON_AUTO_TRANSITION
Deprecated.Automatic playback transition from one period in the timeline to the next.static int
DISCONTINUITY_REASON_INTERNAL
Deprecated.Discontinuity introduced internally (e.g.static int
DISCONTINUITY_REASON_REMOVE
Deprecated.Discontinuity caused by the removal of the current period from theTimeline
.static int
DISCONTINUITY_REASON_SEEK
Deprecated.Seek within the current period or to another period.static int
DISCONTINUITY_REASON_SEEK_ADJUSTMENT
Deprecated.Seek adjustment due to being unable to seek to the requested position or because the seek was permitted to be inexact.static int
DISCONTINUITY_REASON_SKIP
Deprecated.Discontinuity introduced by a skipped period (for instance a skipped ad).static int
EVENT_AUDIO_ATTRIBUTES_CHANGED
Deprecated.getAudioAttributes()
changed.static int
EVENT_AUDIO_SESSION_ID
Deprecated.The audio session id was set.static int
EVENT_AVAILABLE_COMMANDS_CHANGED
Deprecated.isCommandAvailable(int)
changed for at least onePlayer.Command
.static int
EVENT_CUES
Deprecated.getCurrentCues()
changed.static int
EVENT_DEVICE_INFO_CHANGED
Deprecated.getDeviceInfo()
changed.static int
EVENT_DEVICE_VOLUME_CHANGED
Deprecated.getDeviceVolume()
changed.static int
EVENT_IS_LOADING_CHANGED
Deprecated.isLoading()
()} changed.static int
EVENT_IS_PLAYING_CHANGED
Deprecated.isPlaying()
changed.static int
EVENT_MAX_SEEK_TO_PREVIOUS_POSITION_CHANGED
Deprecated.getMaxSeekToPreviousPosition()
changed.static int
EVENT_MEDIA_ITEM_TRANSITION
Deprecated.getCurrentMediaItem()
changed or the player started repeating the current item.static int
EVENT_MEDIA_METADATA_CHANGED
Deprecated.getMediaMetadata()
changed.static int
EVENT_METADATA
Deprecated.Metadata associated with the current playback time changed.static int
EVENT_PLAY_WHEN_READY_CHANGED
Deprecated.getPlayWhenReady()
changed.static int
EVENT_PLAYBACK_PARAMETERS_CHANGED
Deprecated.getPlaybackParameters()
changed.static int
EVENT_PLAYBACK_STATE_CHANGED
Deprecated.getPlaybackState()
changed.static int
EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED
Deprecated.getPlaybackSuppressionReason()
changed.static int
EVENT_PLAYER_ERROR
Deprecated.getPlayerError()
changed.static int
EVENT_PLAYLIST_METADATA_CHANGED
Deprecated.getPlaylistMetadata()
changed.static int
EVENT_POSITION_DISCONTINUITY
Deprecated.A position discontinuity occurred.static int
EVENT_RENDERED_FIRST_FRAME
Deprecated.A frame is rendered for the first time since setting the surface, or since the renderer was reset, or since the stream being rendered was changed.static int
EVENT_REPEAT_MODE_CHANGED
Deprecated.getRepeatMode()
changed.static int
EVENT_SEEK_BACK_INCREMENT_CHANGED
Deprecated.getSeekBackIncrement()
changed.static int
EVENT_SEEK_FORWARD_INCREMENT_CHANGED
Deprecated.getSeekForwardIncrement()
changed.static int
EVENT_SHUFFLE_MODE_ENABLED_CHANGED
Deprecated.getShuffleModeEnabled()
changed.static int
EVENT_SKIP_SILENCE_ENABLED_CHANGED
Deprecated.Skipping silences in the audio stream is enabled or disabled.static int
EVENT_SURFACE_SIZE_CHANGED
Deprecated.The size of the surface onto which the video is being rendered changed.static int
EVENT_TIMELINE_CHANGED
Deprecated.getCurrentTimeline()
changed.static int
EVENT_TRACK_SELECTION_PARAMETERS_CHANGED
Deprecated.getTrackSelectionParameters()
changed.static int
EVENT_TRACKS_CHANGED
Deprecated.getCurrentTracks()
changed.static int
EVENT_VIDEO_SIZE_CHANGED
Deprecated.getVideoSize()
changed.static int
EVENT_VOLUME_CHANGED
Deprecated.getVolume()
changed.static int
MEDIA_ITEM_TRANSITION_REASON_AUTO
Deprecated.Playback has automatically transitioned to the next media item.static int
MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED
Deprecated.The current media item has changed because of a change in the playlist.static int
MEDIA_ITEM_TRANSITION_REASON_REPEAT
Deprecated.The media item has been repeated.static int
MEDIA_ITEM_TRANSITION_REASON_SEEK
Deprecated.A seek to another media item has occurred.static int
PLAY_WHEN_READY_CHANGE_REASON_AUDIO_BECOMING_NOISY
Deprecated.Playback has been paused to avoid becoming noisy.static int
PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS
Deprecated.Playback has been paused because of a loss of audio focus.static int
PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM
Deprecated.Playback has been paused at the end of a media item.static int
PLAY_WHEN_READY_CHANGE_REASON_REMOTE
Deprecated.Playback has been started or paused because of a remote change.static int
PLAY_WHEN_READY_CHANGE_REASON_SUPPRESSED_TOO_LONG
Deprecated.Playback has been paused because playback has been suppressed too long.static int
PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST
Deprecated.Playback has been started or paused by a call tosetPlayWhenReady(boolean)
.static int
PLAYBACK_SUPPRESSION_REASON_NONE
Deprecated.Playback is not suppressed.static int
PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS
Deprecated.Playback is suppressed due to transient audio focus loss.static int
PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_ROUTE
Deprecated.Playback is suppressed due to no suitable audio route, such as an attempt to use an internal speaker instead of bluetooth headphones on Wear OS.static int
REPEAT_MODE_ALL
Deprecated.Repeats the entire timeline infinitely.static int
REPEAT_MODE_OFF
Deprecated.Normal playback without repetition.static int
REPEAT_MODE_ONE
Deprecated.Repeats the currently playingMediaItem
infinitely during ongoing playback.static int
STATE_BUFFERING
Deprecated.The player is not able to immediately play the media, but is doing work toward being able to do so.static int
STATE_ENDED
Deprecated.The player has finished playing the media.static int
STATE_IDLE
Deprecated.The player is idle, meaning it holds only limited resources.static int
STATE_READY
Deprecated.The player is able to immediately play from its current position.static int
TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED
Deprecated.Timeline changed as a result of a change of the playlist items or the order of the items.static int
TIMELINE_CHANGE_REASON_SOURCE_UPDATE
Deprecated.Timeline changed as a result of a source update (e.g.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
addListener(Player.Listener listener)
Deprecated.Registers a listener to receive all events from the player.void
addMediaItem(int index, MediaItem mediaItem)
Deprecated.Adds a media item at the given index of the playlist.void
addMediaItem(MediaItem mediaItem)
Deprecated.Adds a media item to the end of the playlist.void
addMediaItems(int index, List<MediaItem> mediaItems)
Deprecated.Adds a list of media items at the given index of the playlist.void
addMediaItems(List<MediaItem> mediaItems)
Deprecated.Adds a list of media items to the end of the playlist.boolean
canAdvertiseSession()
Deprecated.Returns whether the player can be used to advertise a media session.void
clearMediaItems()
Deprecated.Clears the playlist.void
clearVideoSurface()
Deprecated.void
clearVideoSurface(Surface surface)
Deprecated.Clears theSurface
onto which video is being rendered if it matches the one passed.void
clearVideoSurfaceHolder(SurfaceHolder surfaceHolder)
Deprecated.Clears theSurfaceHolder
that holds theSurface
onto which video is being rendered if it matches the one passed.void
clearVideoSurfaceView(SurfaceView surfaceView)
Deprecated.Clears theSurfaceView
onto which video is being rendered if it matches the one passed.void
clearVideoTextureView(TextureView textureView)
Deprecated.Clears theTextureView
onto which video is being rendered if it matches the one passed.void
decreaseDeviceVolume()
Deprecated.UsedecreaseDeviceVolume(int)
instead.void
decreaseDeviceVolume(@com.google.android.exoplayer2.C.VolumeFlags int flags)
Deprecated.Decreases the volume of the device.Looper
getApplicationLooper()
Deprecated.Returns theLooper
associated with the application thread that's used to access the player and on which player events are received.AudioAttributes
getAudioAttributes()
Deprecated.Returns the attributes for audio playback.Player.Commands
getAvailableCommands()
Deprecated.Returns the player's currently availablePlayer.Commands
.int
getBufferedPercentage()
Deprecated.Returns an estimate of the percentage in the current content or ad up to which data is buffered, or 0 if no estimate is available.long
getBufferedPosition()
Deprecated.Returns an estimate of the position in the current content or ad up to which data is buffered, in milliseconds.long
getContentBufferedPosition()
Deprecated.IfisPlayingAd()
returnstrue
, returns an estimate of the content position in the current content up to which data is buffered, in milliseconds.long
getContentDuration()
Deprecated.IfisPlayingAd()
returnstrue
, returns the duration of the current content in milliseconds, orC.TIME_UNSET
if the duration is not known.long
getContentPosition()
Deprecated.IfisPlayingAd()
returnstrue
, returns the content position that will be played once all ads in the ad group have finished playing, in milliseconds.int
getCurrentAdGroupIndex()
Deprecated.IfisPlayingAd()
returns true, returns the index of the ad group in the period currently being played.int
getCurrentAdIndexInAdGroup()
Deprecated.IfisPlayingAd()
returns true, returns the index of the ad in its ad group.CueGroup
getCurrentCues()
Deprecated.Returns the currentCueGroup
.long
getCurrentLiveOffset()
Deprecated.Returns the offset of the current playback position from the live edge in milliseconds, orC.TIME_UNSET
if the currentMediaItem
isCurrentMediaItemLive()
isn't live} or the offset is unknown.Object
getCurrentManifest()
Deprecated.Returns the current manifest.MediaItem
getCurrentMediaItem()
Deprecated.Returns the currently playingMediaItem
.int
getCurrentMediaItemIndex()
Deprecated.Returns the index of the currentMediaItem
in thetimeline
, or the prospective index if thecurrent timeline
is empty.int
getCurrentPeriodIndex()
Deprecated.Returns the index of the period currently being played.long
getCurrentPosition()
Deprecated.Returns the playback position in the current content or ad, in milliseconds, or the prospective position in milliseconds if thecurrent timeline
is empty.Timeline
getCurrentTimeline()
Deprecated.Returns the currentTimeline
.Tracks
getCurrentTracks()
Deprecated.Returns the current tracks.int
getCurrentWindowIndex()
Deprecated.UsegetCurrentMediaItemIndex()
instead.DeviceInfo
getDeviceInfo()
Deprecated.Gets the device information.int
getDeviceVolume()
Deprecated.Gets the current volume of the device.long
getDuration()
Deprecated.Returns the duration of the current content or ad in milliseconds, orC.TIME_UNSET
if the duration is not known.long
getMaxSeekToPreviousPosition()
Deprecated.Returns the maximum position for whichseekToPrevious()
seeks to the previousMediaItem
, in milliseconds.MediaItem
getMediaItemAt(int index)
Deprecated.Returns theMediaItem
at the given index.int
getMediaItemCount()
Deprecated.Returns the number of media items in the playlist.MediaMetadata
getMediaMetadata()
Deprecated.Returns the current combinedMediaMetadata
, orMediaMetadata.EMPTY
if not supported.int
getNextMediaItemIndex()
Deprecated.Returns the index of theMediaItem
that will be played ifseekToNextMediaItem()
is called, which may depend on the current repeat mode and whether shuffle mode is enabled.int
getNextWindowIndex()
Deprecated.UsegetNextMediaItemIndex()
instead.PlaybackParameters
getPlaybackParameters()
Deprecated.Returns the currently active playback parameters.@com.google.android.exoplayer2.Player.State int
getPlaybackState()
Deprecated.Returns the current playback state of the player.@com.google.android.exoplayer2.Player.PlaybackSuppressionReason int
getPlaybackSuppressionReason()
Deprecated.Returns the reason why playback is suppressed even thoughgetPlayWhenReady()
istrue
, orPLAYBACK_SUPPRESSION_REASON_NONE
if playback is not suppressed.PlaybackException
getPlayerError()
Deprecated.Returns the error that caused playback to fail.MediaMetadata
getPlaylistMetadata()
Deprecated.Returns the playlistMediaMetadata
, as set bysetPlaylistMetadata(MediaMetadata)
, orMediaMetadata.EMPTY
if not supported.boolean
getPlayWhenReady()
Deprecated.Whether playback will proceed whengetPlaybackState()
==STATE_READY
.int
getPreviousMediaItemIndex()
Deprecated.Returns the index of theMediaItem
that will be played ifseekToPreviousMediaItem()
is called, which may depend on the current repeat mode and whether shuffle mode is enabled.int
getPreviousWindowIndex()
Deprecated.UsegetPreviousMediaItemIndex()
instead.@com.google.android.exoplayer2.Player.RepeatMode int
getRepeatMode()
Deprecated.Returns the currentPlayer.RepeatMode
used for playback.long
getSeekBackIncrement()
Deprecated.Returns theseekBack()
increment.long
getSeekForwardIncrement()
Deprecated.Returns theseekForward()
increment.boolean
getShuffleModeEnabled()
Deprecated.Returns whether shuffling of media items is enabled.Size
getSurfaceSize()
Deprecated.Gets the size of the surface on which the video is rendered.long
getTotalBufferedDuration()
Deprecated.Returns an estimate of the total buffered duration from the current position, in milliseconds.TrackSelectionParameters
getTrackSelectionParameters()
Deprecated.Returns the parameters constraining the track selection.VideoSize
getVideoSize()
Deprecated.Gets the size of the video.float
getVolume()
Deprecated.Returns the audio volume, with 0 being silence and 1 being unity gain (signal unchanged).boolean
hasNext()
Deprecated.UsehasNextMediaItem()
instead.boolean
hasNextMediaItem()
Deprecated.Returns whether a nextMediaItem
exists, which may depend on the current repeat mode and whether shuffle mode is enabled.boolean
hasNextWindow()
Deprecated.UsehasNextMediaItem()
instead.boolean
hasPrevious()
Deprecated.UsehasPreviousMediaItem()
instead.boolean
hasPreviousMediaItem()
Deprecated.Returns whether a previous media item exists, which may depend on the current repeat mode and whether shuffle mode is enabled.boolean
hasPreviousWindow()
Deprecated.UsehasPreviousMediaItem()
instead.void
increaseDeviceVolume()
Deprecated.UseincreaseDeviceVolume(int)
instead.void
increaseDeviceVolume(@com.google.android.exoplayer2.C.VolumeFlags int flags)
Deprecated.Increases the volume of the device.boolean
isCommandAvailable(@com.google.android.exoplayer2.Player.Command int command)
Deprecated.Returns whether the providedPlayer.Command
is available.boolean
isCurrentMediaItemDynamic()
Deprecated.boolean
isCurrentMediaItemLive()
Deprecated.boolean
isCurrentMediaItemSeekable()
Deprecated.boolean
isCurrentWindowDynamic()
Deprecated.UseisCurrentMediaItemDynamic()
instead.boolean
isCurrentWindowLive()
Deprecated.UseisCurrentMediaItemLive()
instead.boolean
isCurrentWindowSeekable()
Deprecated.UseisCurrentMediaItemSeekable()
instead.boolean
isDeviceMuted()
Deprecated.Gets whether the device is muted or not.boolean
isLoading()
Deprecated.Whether the player is currently loading the source.boolean
isPlaying()
Deprecated.Returns whether the player is playing, i.e.boolean
isPlayingAd()
Deprecated.Returns whether the player is currently playing an ad.void
moveMediaItem(int currentIndex, int newIndex)
Deprecated.Moves the media item at the current index to the new index.void
moveMediaItems(int fromIndex, int toIndex, int newIndex)
Deprecated.Moves the media item range to the new index.void
next()
Deprecated.UseseekToNextMediaItem()
instead.void
pause()
Deprecated.Pauses playback.void
play()
Deprecated.Resumes playback as soon asgetPlaybackState()
==STATE_READY
.void
prepare()
Deprecated.Prepares the player.void
previous()
Deprecated.UseseekToPreviousMediaItem()
instead.void
release()
Deprecated.Releases the player.void
removeListener(Player.Listener listener)
Deprecated.Unregister a listener registered throughaddListener(Listener)
.void
removeMediaItem(int index)
Deprecated.Removes the media item at the given index of the playlist.void
removeMediaItems(int fromIndex, int toIndex)
Deprecated.Removes a range of media items from the playlist.void
replaceMediaItem(int index, MediaItem mediaItem)
Deprecated.Replaces the media item at the given index of the playlist.void
replaceMediaItems(int fromIndex, int toIndex, List<MediaItem> mediaItems)
Deprecated.Replaces the media items at the given range of the playlist.void
seekBack()
Deprecated.Seeks back in the currentMediaItem
bygetSeekBackIncrement()
milliseconds.void
seekForward()
Deprecated.Seeks forward in the currentMediaItem
bygetSeekForwardIncrement()
milliseconds.void
seekTo(int mediaItemIndex, long positionMs)
Deprecated.Seeks to a position specified in milliseconds in the specifiedMediaItem
.void
seekTo(long positionMs)
Deprecated.Seeks to a position specified in milliseconds in the currentMediaItem
.void
seekToDefaultPosition()
Deprecated.Seeks to the default position associated with the currentMediaItem
.void
seekToDefaultPosition(int mediaItemIndex)
Deprecated.Seeks to the default position associated with the specifiedMediaItem
.void
seekToNext()
Deprecated.Seeks to a later position in the current or nextMediaItem
(if available).void
seekToNextMediaItem()
Deprecated.Seeks to the default position of the nextMediaItem
, which may depend on the current repeat mode and whether shuffle mode is enabled.void
seekToNextWindow()
Deprecated.UseseekToNextMediaItem()
instead.void
seekToPrevious()
Deprecated.Seeks to an earlier position in the current or previousMediaItem
(if available).void
seekToPreviousMediaItem()
Deprecated.Seeks to the default position of the previousMediaItem
, which may depend on the current repeat mode and whether shuffle mode is enabled.void
seekToPreviousWindow()
Deprecated.UseseekToPreviousMediaItem()
instead.void
setDeviceMuted(boolean muted)
Deprecated.UsesetDeviceMuted(boolean, int)
instead.void
setDeviceMuted(boolean muted, @com.google.android.exoplayer2.C.VolumeFlags int flags)
Deprecated.Sets the mute state of the device.void
setDeviceVolume(int volume)
Deprecated.UsesetDeviceVolume(int, int)
instead.void
setDeviceVolume(int volume, int flags)
Deprecated.Sets the volume of the device with volume flags.void
setMediaItem(MediaItem mediaItem)
Deprecated.Clears the playlist, adds the specifiedMediaItem
and resets the position to the default position.void
setMediaItem(MediaItem mediaItem, boolean resetPosition)
Deprecated.Clears the playlist and adds the specifiedMediaItem
.void
setMediaItem(MediaItem mediaItem, long startPositionMs)
Deprecated.Clears the playlist and adds the specifiedMediaItem
.void
setMediaItems(List<MediaItem> mediaItems)
Deprecated.Clears the playlist, adds the specified media items and resets the position to the default position.void
setMediaItems(List<MediaItem> mediaItems, boolean resetPosition)
Deprecated.Clears the playlist and adds the specified media items.void
setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs)
Deprecated.Clears the playlist and adds the specified media items.void
setPlaybackParameters(PlaybackParameters playbackParameters)
Deprecated.Attempts to set the playback parameters.void
setPlaybackSpeed(float speed)
Deprecated.Changes the rate at which playback occurs.void
setPlaylistMetadata(MediaMetadata mediaMetadata)
Deprecated.Sets the playlistMediaMetadata
.void
setPlayWhenReady(boolean playWhenReady)
Deprecated.Sets whether playback should proceed whengetPlaybackState()
==STATE_READY
.void
setRepeatMode(@com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
Deprecated.Sets thePlayer.RepeatMode
to be used for playback.void
setShuffleModeEnabled(boolean shuffleModeEnabled)
Deprecated.Sets whether shuffling of media items is enabled.void
setTrackSelectionParameters(TrackSelectionParameters parameters)
Deprecated.Sets the parameters constraining the track selection.void
setVideoSurface(Surface surface)
Deprecated.Sets theSurface
onto which video will be rendered.void
setVideoSurfaceHolder(SurfaceHolder surfaceHolder)
Deprecated.Sets theSurfaceHolder
that holds theSurface
onto which video will be rendered.void
setVideoSurfaceView(SurfaceView surfaceView)
Deprecated.Sets theSurfaceView
onto which video will be rendered.void
setVideoTextureView(TextureView textureView)
Deprecated.Sets theTextureView
onto which video will be rendered.void
setVolume(float volume)
Deprecated.Sets the audio volume, valid values are between 0 (silence) and 1 (unity gain, signal unchanged), inclusive.void
stop()
Deprecated.Stops playback without resetting the playlist.
-
-
-
Field Detail
-
STATE_IDLE
static final int STATE_IDLE
Deprecated.The player is idle, meaning it holds only limited resources. The player must beprepared
before it will play the media.- See Also:
- Constant Field Values
-
STATE_BUFFERING
static final int STATE_BUFFERING
Deprecated.The player is not able to immediately play the media, but is doing work toward being able to do so. This state typically occurs when the player needs to buffer more data before playback can start.- See Also:
- Constant Field Values
-
STATE_READY
static final int STATE_READY
Deprecated.The player is able to immediately play from its current position. The player will be playing ifgetPlayWhenReady()
is true, and paused otherwise.- See Also:
- Constant Field Values
-
STATE_ENDED
static final int STATE_ENDED
Deprecated.The player has finished playing the media.- See Also:
- Constant Field Values
-
PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST
static final int PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST
Deprecated.Playback has been started or paused by a call tosetPlayWhenReady(boolean)
.- See Also:
- Constant Field Values
-
PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS
static final int PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS
Deprecated.Playback has been paused because of a loss of audio focus.- See Also:
- Constant Field Values
-
PLAY_WHEN_READY_CHANGE_REASON_AUDIO_BECOMING_NOISY
static final int PLAY_WHEN_READY_CHANGE_REASON_AUDIO_BECOMING_NOISY
Deprecated.Playback has been paused to avoid becoming noisy.- See Also:
- Constant Field Values
-
PLAY_WHEN_READY_CHANGE_REASON_REMOTE
static final int PLAY_WHEN_READY_CHANGE_REASON_REMOTE
Deprecated.Playback has been started or paused because of a remote change.- See Also:
- Constant Field Values
-
PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM
static final int PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM
Deprecated.Playback has been paused at the end of a media item.- See Also:
- Constant Field Values
-
PLAY_WHEN_READY_CHANGE_REASON_SUPPRESSED_TOO_LONG
static final int PLAY_WHEN_READY_CHANGE_REASON_SUPPRESSED_TOO_LONG
Deprecated.Playback has been paused because playback has been suppressed too long.- See Also:
- Constant Field Values
-
PLAYBACK_SUPPRESSION_REASON_NONE
static final int PLAYBACK_SUPPRESSION_REASON_NONE
Deprecated.Playback is not suppressed.- See Also:
- Constant Field Values
-
PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS
static final int PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS
Deprecated.Playback is suppressed due to transient audio focus loss.- See Also:
- Constant Field Values
-
PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_ROUTE
static final int PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_ROUTE
Deprecated.Playback is suppressed due to no suitable audio route, such as an attempt to use an internal speaker instead of bluetooth headphones on Wear OS.- See Also:
- Constant Field Values
-
REPEAT_MODE_OFF
static final int REPEAT_MODE_OFF
Deprecated.Normal playback without repetition. "Previous" and "Next" actions move to the previous and nextMediaItem
respectively, and do nothing when there is no previous or nextMediaItem
to move to.- See Also:
- Constant Field Values
-
REPEAT_MODE_ONE
static final int REPEAT_MODE_ONE
Deprecated.Repeats the currently playingMediaItem
infinitely during ongoing playback. "Previous" and "Next" actions behave as they do inREPEAT_MODE_OFF
, moving to the previous and nextMediaItem
respectively, and doing nothing when there is no previous or nextMediaItem
to move to.- See Also:
- Constant Field Values
-
REPEAT_MODE_ALL
static final int REPEAT_MODE_ALL
Deprecated.Repeats the entire timeline infinitely. "Previous" and "Next" actions behave as they do inREPEAT_MODE_OFF
, but with looping at the ends so that "Previous" when playing the firstMediaItem
will move to the lastMediaItem
, and "Next" when playing the lastMediaItem
will move to the firstMediaItem
.- See Also:
- Constant Field Values
-
DISCONTINUITY_REASON_AUTO_TRANSITION
static final int DISCONTINUITY_REASON_AUTO_TRANSITION
Deprecated.Automatic playback transition from one period in the timeline to the next. The period index may be the same as it was before the discontinuity in case the current period is repeated.This reason also indicates an automatic transition from the content period to an inserted ad period or vice versa. Or a transition caused by another player (e.g. multiple controllers can control the same playback on a remote device).
- See Also:
- Constant Field Values
-
DISCONTINUITY_REASON_SEEK
static final int DISCONTINUITY_REASON_SEEK
Deprecated.Seek within the current period or to another period.- See Also:
- Constant Field Values
-
DISCONTINUITY_REASON_SEEK_ADJUSTMENT
static final int DISCONTINUITY_REASON_SEEK_ADJUSTMENT
Deprecated.Seek adjustment due to being unable to seek to the requested position or because the seek was permitted to be inexact.- See Also:
- Constant Field Values
-
DISCONTINUITY_REASON_SKIP
static final int DISCONTINUITY_REASON_SKIP
Deprecated.Discontinuity introduced by a skipped period (for instance a skipped ad).- See Also:
- Constant Field Values
-
DISCONTINUITY_REASON_REMOVE
static final int DISCONTINUITY_REASON_REMOVE
Deprecated.Discontinuity caused by the removal of the current period from theTimeline
.- See Also:
- Constant Field Values
-
DISCONTINUITY_REASON_INTERNAL
static final int DISCONTINUITY_REASON_INTERNAL
Deprecated.Discontinuity introduced internally (e.g. by the source).- See Also:
- Constant Field Values
-
TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED
static final int TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED
Deprecated.Timeline changed as a result of a change of the playlist items or the order of the items.- See Also:
- Constant Field Values
-
TIMELINE_CHANGE_REASON_SOURCE_UPDATE
static final int TIMELINE_CHANGE_REASON_SOURCE_UPDATE
Deprecated.Timeline changed as a result of a source update (e.g. result of a dynamic update by the played media).This reason also indicates a change caused by another player (e.g. multiple controllers can control the same playback on the remote device).
- See Also:
- Constant Field Values
-
MEDIA_ITEM_TRANSITION_REASON_REPEAT
static final int MEDIA_ITEM_TRANSITION_REASON_REPEAT
Deprecated.The media item has been repeated.- See Also:
- Constant Field Values
-
MEDIA_ITEM_TRANSITION_REASON_AUTO
static final int MEDIA_ITEM_TRANSITION_REASON_AUTO
Deprecated.Playback has automatically transitioned to the next media item.This reason also indicates a transition caused by another player (e.g. multiple controllers can control the same playback on a remote device).
- See Also:
- Constant Field Values
-
MEDIA_ITEM_TRANSITION_REASON_SEEK
static final int MEDIA_ITEM_TRANSITION_REASON_SEEK
Deprecated.A seek to another media item has occurred.- See Also:
- Constant Field Values
-
MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED
static final int MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED
Deprecated.The current media item has changed because of a change in the playlist. This can either be if the media item previously being played has been removed, or when the playlist becomes non-empty after being empty.- See Also:
- Constant Field Values
-
EVENT_TIMELINE_CHANGED
static final int EVENT_TIMELINE_CHANGED
Deprecated.getCurrentTimeline()
changed.- See Also:
- Constant Field Values
-
EVENT_MEDIA_ITEM_TRANSITION
static final int EVENT_MEDIA_ITEM_TRANSITION
Deprecated.getCurrentMediaItem()
changed or the player started repeating the current item.- See Also:
- Constant Field Values
-
EVENT_TRACKS_CHANGED
static final int EVENT_TRACKS_CHANGED
Deprecated.getCurrentTracks()
changed.- See Also:
- Constant Field Values
-
EVENT_IS_LOADING_CHANGED
static final int EVENT_IS_LOADING_CHANGED
Deprecated.isLoading()
()} changed.- See Also:
- Constant Field Values
-
EVENT_PLAYBACK_STATE_CHANGED
static final int EVENT_PLAYBACK_STATE_CHANGED
Deprecated.getPlaybackState()
changed.- See Also:
- Constant Field Values
-
EVENT_PLAY_WHEN_READY_CHANGED
static final int EVENT_PLAY_WHEN_READY_CHANGED
Deprecated.getPlayWhenReady()
changed.- See Also:
- Constant Field Values
-
EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED
static final int EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED
Deprecated.getPlaybackSuppressionReason()
changed.- See Also:
- Constant Field Values
-
EVENT_IS_PLAYING_CHANGED
static final int EVENT_IS_PLAYING_CHANGED
Deprecated.isPlaying()
changed.- See Also:
- Constant Field Values
-
EVENT_REPEAT_MODE_CHANGED
static final int EVENT_REPEAT_MODE_CHANGED
Deprecated.getRepeatMode()
changed.- See Also:
- Constant Field Values
-
EVENT_SHUFFLE_MODE_ENABLED_CHANGED
static final int EVENT_SHUFFLE_MODE_ENABLED_CHANGED
Deprecated.getShuffleModeEnabled()
changed.- See Also:
- Constant Field Values
-
EVENT_PLAYER_ERROR
static final int EVENT_PLAYER_ERROR
Deprecated.getPlayerError()
changed.- See Also:
- Constant Field Values
-
EVENT_POSITION_DISCONTINUITY
static final int EVENT_POSITION_DISCONTINUITY
Deprecated.A position discontinuity occurred. SeePlayer.Listener.onPositionDiscontinuity(PositionInfo, PositionInfo, int)
.- See Also:
- Constant Field Values
-
EVENT_PLAYBACK_PARAMETERS_CHANGED
static final int EVENT_PLAYBACK_PARAMETERS_CHANGED
Deprecated.getPlaybackParameters()
changed.- See Also:
- Constant Field Values
-
EVENT_AVAILABLE_COMMANDS_CHANGED
static final int EVENT_AVAILABLE_COMMANDS_CHANGED
Deprecated.isCommandAvailable(int)
changed for at least onePlayer.Command
.- See Also:
- Constant Field Values
-
EVENT_MEDIA_METADATA_CHANGED
static final int EVENT_MEDIA_METADATA_CHANGED
Deprecated.getMediaMetadata()
changed.- See Also:
- Constant Field Values
-
EVENT_PLAYLIST_METADATA_CHANGED
static final int EVENT_PLAYLIST_METADATA_CHANGED
Deprecated.getPlaylistMetadata()
changed.- See Also:
- Constant Field Values
-
EVENT_SEEK_BACK_INCREMENT_CHANGED
static final int EVENT_SEEK_BACK_INCREMENT_CHANGED
Deprecated.getSeekBackIncrement()
changed.- See Also:
- Constant Field Values
-
EVENT_SEEK_FORWARD_INCREMENT_CHANGED
static final int EVENT_SEEK_FORWARD_INCREMENT_CHANGED
Deprecated.getSeekForwardIncrement()
changed.- See Also:
- Constant Field Values
-
EVENT_MAX_SEEK_TO_PREVIOUS_POSITION_CHANGED
static final int EVENT_MAX_SEEK_TO_PREVIOUS_POSITION_CHANGED
Deprecated.getMaxSeekToPreviousPosition()
changed.- See Also:
- Constant Field Values
-
EVENT_TRACK_SELECTION_PARAMETERS_CHANGED
static final int EVENT_TRACK_SELECTION_PARAMETERS_CHANGED
Deprecated.getTrackSelectionParameters()
changed.- See Also:
- Constant Field Values
-
EVENT_AUDIO_ATTRIBUTES_CHANGED
static final int EVENT_AUDIO_ATTRIBUTES_CHANGED
Deprecated.getAudioAttributes()
changed.- See Also:
- Constant Field Values
-
EVENT_AUDIO_SESSION_ID
static final int EVENT_AUDIO_SESSION_ID
Deprecated.The audio session id was set.- See Also:
- Constant Field Values
-
EVENT_VOLUME_CHANGED
static final int EVENT_VOLUME_CHANGED
Deprecated.getVolume()
changed.- See Also:
- Constant Field Values
-
EVENT_SKIP_SILENCE_ENABLED_CHANGED
static final int EVENT_SKIP_SILENCE_ENABLED_CHANGED
Deprecated.Skipping silences in the audio stream is enabled or disabled.- See Also:
- Constant Field Values
-
EVENT_SURFACE_SIZE_CHANGED
static final int EVENT_SURFACE_SIZE_CHANGED
Deprecated.The size of the surface onto which the video is being rendered changed.- See Also:
- Constant Field Values
-
EVENT_VIDEO_SIZE_CHANGED
static final int EVENT_VIDEO_SIZE_CHANGED
Deprecated.getVideoSize()
changed.- See Also:
- Constant Field Values
-
EVENT_RENDERED_FIRST_FRAME
static final int EVENT_RENDERED_FIRST_FRAME
Deprecated.A frame is rendered for the first time since setting the surface, or since the renderer was reset, or since the stream being rendered was changed.- See Also:
- Constant Field Values
-
EVENT_CUES
static final int EVENT_CUES
Deprecated.getCurrentCues()
changed.- See Also:
- Constant Field Values
-
EVENT_METADATA
static final int EVENT_METADATA
Deprecated.Metadata associated with the current playback time changed.- See Also:
- Constant Field Values
-
EVENT_DEVICE_INFO_CHANGED
static final int EVENT_DEVICE_INFO_CHANGED
Deprecated.getDeviceInfo()
changed.- See Also:
- Constant Field Values
-
EVENT_DEVICE_VOLUME_CHANGED
static final int EVENT_DEVICE_VOLUME_CHANGED
Deprecated.getDeviceVolume()
changed.- See Also:
- Constant Field Values
-
COMMAND_PLAY_PAUSE
static final int COMMAND_PLAY_PAUSE
Deprecated.Command to start, pause or resume playback.The following methods must only be called if this command is available:
- See Also:
- Constant Field Values
-
COMMAND_PREPARE
static final int COMMAND_PREPARE
Deprecated.Command to prepare the player.The
prepare()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_STOP
static final int COMMAND_STOP
Deprecated.- See Also:
- Constant Field Values
-
COMMAND_SEEK_TO_DEFAULT_POSITION
static final int COMMAND_SEEK_TO_DEFAULT_POSITION
Deprecated.Command to seek to the default position of the currentMediaItem
.The
seekToDefaultPosition()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
static final int COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
Deprecated.Command to seek anywhere inside the currentMediaItem
.The
seekTo(long)
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_SEEK_IN_CURRENT_WINDOW
@Deprecated static final int COMMAND_SEEK_IN_CURRENT_WINDOW
Deprecated.UseCOMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
instead.- See Also:
- Constant Field Values
-
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
static final int COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
Deprecated.Command to seek to the default position of the previousMediaItem
.The
seekToPreviousMediaItem()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_SEEK_TO_PREVIOUS_WINDOW
@Deprecated static final int COMMAND_SEEK_TO_PREVIOUS_WINDOW
Deprecated.UseCOMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
instead.- See Also:
- Constant Field Values
-
COMMAND_SEEK_TO_PREVIOUS
static final int COMMAND_SEEK_TO_PREVIOUS
Deprecated.Command to seek to an earlier position in the currentMediaItem
or the default position of the previousMediaItem
.The
seekToPrevious()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
static final int COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
Deprecated.Command to seek to the default position of the nextMediaItem
.The
seekToNextMediaItem()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_SEEK_TO_NEXT_WINDOW
@Deprecated static final int COMMAND_SEEK_TO_NEXT_WINDOW
Deprecated.UseCOMMAND_SEEK_TO_NEXT_MEDIA_ITEM
instead.- See Also:
- Constant Field Values
-
COMMAND_SEEK_TO_NEXT
static final int COMMAND_SEEK_TO_NEXT
Deprecated.Command to seek to a later position in the currentMediaItem
or the default position of the nextMediaItem
.The
seekToNext()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_SEEK_TO_MEDIA_ITEM
static final int COMMAND_SEEK_TO_MEDIA_ITEM
Deprecated.Command to seek anywhere in anyMediaItem
.The following methods must only be called if this command is available:
- See Also:
- Constant Field Values
-
COMMAND_SEEK_TO_WINDOW
@Deprecated static final int COMMAND_SEEK_TO_WINDOW
Deprecated.UseCOMMAND_SEEK_TO_MEDIA_ITEM
instead.- See Also:
- Constant Field Values
-
COMMAND_SEEK_BACK
static final int COMMAND_SEEK_BACK
Deprecated.Command to seek back by a fixed increment inside the currentMediaItem
.The
seekBack()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_SEEK_FORWARD
static final int COMMAND_SEEK_FORWARD
Deprecated.Command to seek forward by a fixed increment inside the currentMediaItem
.The
seekForward()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_SET_SPEED_AND_PITCH
static final int COMMAND_SET_SPEED_AND_PITCH
Deprecated.Command to set the playback speed and pitch.The following methods must only be called if this command is available:
- See Also:
- Constant Field Values
-
COMMAND_SET_SHUFFLE_MODE
static final int COMMAND_SET_SHUFFLE_MODE
Deprecated.Command to enable shuffling.The
setShuffleModeEnabled(boolean)
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_SET_REPEAT_MODE
static final int COMMAND_SET_REPEAT_MODE
Deprecated.Command to set the repeat mode.The
setRepeatMode(int)
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_GET_CURRENT_MEDIA_ITEM
static final int COMMAND_GET_CURRENT_MEDIA_ITEM
Deprecated.Command to get information about the currently playingMediaItem
.The following methods must only be called if this command is available:
getCurrentMediaItem()
isCurrentMediaItemDynamic()
isCurrentMediaItemLive()
isCurrentMediaItemSeekable()
getCurrentLiveOffset()
getDuration()
getCurrentPosition()
getBufferedPosition()
getContentDuration()
getContentPosition()
getContentBufferedPosition()
getTotalBufferedDuration()
isPlayingAd()
getCurrentAdGroupIndex()
getCurrentAdIndexInAdGroup()
- See Also:
- Constant Field Values
-
COMMAND_GET_TIMELINE
static final int COMMAND_GET_TIMELINE
Deprecated.Command to get the information about the current timeline.The following methods must only be called if this command is available:
- See Also:
- Constant Field Values
-
COMMAND_GET_MEDIA_ITEMS_METADATA
@Deprecated static final int COMMAND_GET_MEDIA_ITEMS_METADATA
Deprecated.UseCOMMAND_GET_METADATA
instead.- See Also:
- Constant Field Values
-
COMMAND_GET_METADATA
static final int COMMAND_GET_METADATA
Deprecated.Command to get metadata related to the playlist and currentMediaItem
.The following methods must only be called if this command is available:
- See Also:
- Constant Field Values
-
COMMAND_SET_MEDIA_ITEMS_METADATA
@Deprecated static final int COMMAND_SET_MEDIA_ITEMS_METADATA
Deprecated.UseCOMMAND_SET_PLAYLIST_METADATA
instead.- See Also:
- Constant Field Values
-
COMMAND_SET_PLAYLIST_METADATA
static final int COMMAND_SET_PLAYLIST_METADATA
Deprecated.Command to set the playlist metadata.The
setPlaylistMetadata(MediaMetadata)
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_SET_MEDIA_ITEM
static final int COMMAND_SET_MEDIA_ITEM
Deprecated.- See Also:
- Constant Field Values
-
COMMAND_CHANGE_MEDIA_ITEMS
static final int COMMAND_CHANGE_MEDIA_ITEMS
Deprecated.Command to change the media items in the playlist.The following methods must only be called if this command is available:
addMediaItem(MediaItem)
addMediaItem(int, MediaItem)
addMediaItems(List)
addMediaItems(int, List)
clearMediaItems()
moveMediaItem(int, int)
moveMediaItems(int, int, int)
removeMediaItem(int)
removeMediaItems(int, int)
setMediaItems(List)
setMediaItems(List, boolean)
setMediaItems(List, int, long)
replaceMediaItem(int, MediaItem)
replaceMediaItems(int, int, List)
- See Also:
- Constant Field Values
-
COMMAND_GET_AUDIO_ATTRIBUTES
static final int COMMAND_GET_AUDIO_ATTRIBUTES
Deprecated.Command to get the player currentAudioAttributes
.The
getAudioAttributes()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_GET_VOLUME
static final int COMMAND_GET_VOLUME
Deprecated.Command to get the player volume.The
getVolume()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_GET_DEVICE_VOLUME
static final int COMMAND_GET_DEVICE_VOLUME
Deprecated.Command to get the device volume and whether it is muted.The following methods must only be called if this command is available:
- See Also:
- Constant Field Values
-
COMMAND_SET_VOLUME
static final int COMMAND_SET_VOLUME
Deprecated.Command to set the player volume.The
setVolume(float)
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_SET_DEVICE_VOLUME
@Deprecated static final int COMMAND_SET_DEVICE_VOLUME
Deprecated.UseCOMMAND_SET_DEVICE_VOLUME_WITH_FLAGS
instead.- See Also:
- Constant Field Values
-
COMMAND_SET_DEVICE_VOLUME_WITH_FLAGS
static final int COMMAND_SET_DEVICE_VOLUME_WITH_FLAGS
Deprecated.Command to set the device volume with volume flags.The
setDeviceVolume(int, int)
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_ADJUST_DEVICE_VOLUME
@Deprecated static final int COMMAND_ADJUST_DEVICE_VOLUME
Deprecated.UseCOMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS
instead.- See Also:
- Constant Field Values
-
COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS
static final int COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS
Deprecated.Command to increase and decrease the device volume and mute it with volume flags.The following methods must only be called if this command is available:
- See Also:
- Constant Field Values
-
COMMAND_SET_VIDEO_SURFACE
static final int COMMAND_SET_VIDEO_SURFACE
Deprecated.Command to set and clear the surface on which to render the video.The following methods must only be called if this command is available:
- See Also:
- Constant Field Values
-
COMMAND_GET_TEXT
static final int COMMAND_GET_TEXT
Deprecated.Command to get the text that should currently be displayed by the player.The
getCurrentCues()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_SET_TRACK_SELECTION_PARAMETERS
static final int COMMAND_SET_TRACK_SELECTION_PARAMETERS
Deprecated.Command to set the player's track selection parameters.The
setTrackSelectionParameters(TrackSelectionParameters)
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_GET_TRACKS
static final int COMMAND_GET_TRACKS
Deprecated.Command to get details of the current track selection.The
getCurrentTracks()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_RELEASE
static final int COMMAND_RELEASE
Deprecated.Command to release the player.The
release()
method must only be called if this command is available.- See Also:
- Constant Field Values
-
COMMAND_INVALID
static final int COMMAND_INVALID
Deprecated.Represents an invalidPlayer.Command
.- See Also:
- Constant Field Values
-
-
Method Detail
-
getApplicationLooper
Looper getApplicationLooper()
Deprecated.Returns theLooper
associated with the application thread that's used to access the player and on which player events are received.This method can be called from any thread.
-
addListener
void addListener(Player.Listener listener)
Deprecated.Registers a listener to receive all events from the player.The listener's methods will be called on the thread associated with
getApplicationLooper()
.This method can be called from any thread.
- Parameters:
listener
- The listener to register.
-
removeListener
void removeListener(Player.Listener listener)
Deprecated.Unregister a listener registered throughaddListener(Listener)
. The listener will no longer receive events.- Parameters:
listener
- The listener to unregister.
-
setMediaItems
void setMediaItems(List<MediaItem> mediaItems)
Deprecated.Clears the playlist, adds the specified media items and resets the position to the default position.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.- Parameters:
mediaItems
- The new media items.
-
setMediaItems
void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition)
Deprecated.Clears the playlist and adds the specified media items.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.- Parameters:
mediaItems
- The new media items.resetPosition
- Whether the playback position should be reset to the default position in the firstTimeline.Window
. If false, playback will start from the position defined bygetCurrentMediaItemIndex()
andgetCurrentPosition()
.
-
setMediaItems
void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs)
Deprecated.Clears the playlist and adds the specified media items.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.- Parameters:
mediaItems
- The new media items.startIndex
- TheMediaItem
index to start playback from. IfC.INDEX_UNSET
is passed, the current position is not reset.startPositionMs
- The position in milliseconds to start playback from. IfC.TIME_UNSET
is passed, the default position of the givenMediaItem
is used. In any case, ifstartIndex
is set toC.INDEX_UNSET
, this parameter is ignored and the position is not reset at all.- Throws:
IllegalSeekPositionException
- If the providedstartIndex
is not within the bounds of the list of media items.
-
setMediaItem
void setMediaItem(MediaItem mediaItem)
Deprecated.Clears the playlist, adds the specifiedMediaItem
and resets the position to the default position.This method must only be called if
COMMAND_SET_MEDIA_ITEM
is available.- Parameters:
mediaItem
- The newMediaItem
.
-
setMediaItem
void setMediaItem(MediaItem mediaItem, long startPositionMs)
Deprecated.Clears the playlist and adds the specifiedMediaItem
.This method must only be called if
COMMAND_SET_MEDIA_ITEM
is available.- Parameters:
mediaItem
- The newMediaItem
.startPositionMs
- The position in milliseconds to start playback from.
-
setMediaItem
void setMediaItem(MediaItem mediaItem, boolean resetPosition)
Deprecated.Clears the playlist and adds the specifiedMediaItem
.This method must only be called if
COMMAND_SET_MEDIA_ITEM
is available.- Parameters:
mediaItem
- The newMediaItem
.resetPosition
- Whether the playback position should be reset to the default position. If false, playback will start from the position defined bygetCurrentMediaItemIndex()
andgetCurrentPosition()
.
-
addMediaItem
void addMediaItem(MediaItem mediaItem)
Deprecated.Adds a media item to the end of the playlist.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.- Parameters:
mediaItem
- TheMediaItem
to add.
-
addMediaItem
void addMediaItem(int index, MediaItem mediaItem)
Deprecated.Adds a media item at the given index of the playlist.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.- Parameters:
index
- The index at which to add the media item. If the index is larger than the size of the playlist, the media item is added to the end of the playlist.mediaItem
- TheMediaItem
to add.
-
addMediaItems
void addMediaItems(List<MediaItem> mediaItems)
Deprecated.Adds a list of media items to the end of the playlist.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.- Parameters:
mediaItems
- The media items to add.
-
addMediaItems
void addMediaItems(int index, List<MediaItem> mediaItems)
Deprecated.Adds a list of media items at the given index of the playlist.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.- Parameters:
index
- The index at which to add the media items. If the index is larger than the size of the playlist, the media items are added to the end of the playlist.mediaItems
- The media items to add.
-
moveMediaItem
void moveMediaItem(int currentIndex, int newIndex)
Deprecated.Moves the media item at the current index to the new index.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.- Parameters:
currentIndex
- The current index of the media item to move. If the index is larger than the size of the playlist, the request is ignored.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.
-
moveMediaItems
void moveMediaItems(int fromIndex, int toIndex, int newIndex)
Deprecated.Moves the media item range to the new index.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.- Parameters:
fromIndex
- The start of the range to move. If the index is larger than the size of the playlist, the request is ignored.toIndex
- The first item not to be included in the range (exclusive). If the index is larger than the size of the playlist, items up to the end of the playlist are moved.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.
-
replaceMediaItem
void replaceMediaItem(int index, MediaItem mediaItem)
Deprecated.Replaces the media item at the given index of the playlist.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.- Parameters:
index
- The index at which to replace the media item. If the index is larger than the size of the playlist, the request is ignored.mediaItem
- The newMediaItem
.
-
replaceMediaItems
void replaceMediaItems(int fromIndex, int toIndex, List<MediaItem> mediaItems)
Deprecated.Replaces the media items at the given range of the playlist.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.Note that it is possible to replace a range with an arbitrary number of new items, so that the number of removed items defined by
fromIndex
andtoIndex
does not have to match the number of added items defined bymediaItems
. As result, it may also change the index of subsequent items not touched by this operation.- Parameters:
fromIndex
- The start of the range. If the index is larger than the size of the playlist, the request is ignored.toIndex
- The first item not to be included in the range (exclusive). If the index is larger than the size of the playlist, items up to the end of the playlist are replaced.mediaItems
- The media items to replace the range with.
-
removeMediaItem
void removeMediaItem(int index)
Deprecated.Removes the media item at the given index of the playlist.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.- Parameters:
index
- The index at which to remove the media item. If the index is larger than the size of the playlist, the request is ignored.
-
removeMediaItems
void removeMediaItems(int fromIndex, int toIndex)
Deprecated.Removes a range of media items from the playlist.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.- Parameters:
fromIndex
- The index at which to start removing media items. If the index is larger than the size of the playlist, the request is ignored.toIndex
- The index of the first item to be kept (exclusive). If the index is larger than the size of the playlist, media items up to the end of the playlist are removed.
-
clearMediaItems
void clearMediaItems()
Deprecated.Clears the playlist.This method must only be called if
COMMAND_CHANGE_MEDIA_ITEMS
is available.
-
isCommandAvailable
boolean isCommandAvailable(@Command @com.google.android.exoplayer2.Player.Command int command)
Deprecated.Returns whether the providedPlayer.Command
is available.This method does not execute the command.
- Parameters:
command
- APlayer.Command
.- Returns:
- Whether the
Player.Command
is available. - See Also:
Player.Listener.onAvailableCommandsChanged(Commands)
-
canAdvertiseSession
boolean canAdvertiseSession()
Deprecated.Returns whether the player can be used to advertise a media session.
-
getAvailableCommands
Player.Commands getAvailableCommands()
Deprecated.Returns the player's currently availablePlayer.Commands
.The returned
Player.Commands
are not updated when available commands change. UsePlayer.Listener.onAvailableCommandsChanged(Commands)
to get an update when the available commands change.- Returns:
- The currently available
Player.Commands
. - See Also:
Player.Listener.onAvailableCommandsChanged(com.google.android.exoplayer2.Player.Commands)
-
prepare
void prepare()
Deprecated.Prepares the player.This method must only be called if
COMMAND_PREPARE
is available.This will move the player out of
idle state
and the player will start loading media and acquire resources needed for playback.
-
getPlaybackState
@State @com.google.android.exoplayer2.Player.State int getPlaybackState()
Deprecated.Returns the current playback state of the player.- Returns:
- The current playback state.
- See Also:
Player.Listener.onPlaybackStateChanged(int)
-
getPlaybackSuppressionReason
@PlaybackSuppressionReason @com.google.android.exoplayer2.Player.PlaybackSuppressionReason int getPlaybackSuppressionReason()
Deprecated.Returns the reason why playback is suppressed even thoughgetPlayWhenReady()
istrue
, orPLAYBACK_SUPPRESSION_REASON_NONE
if playback is not suppressed.- Returns:
- The current
Player.PlaybackSuppressionReason
. - See Also:
Player.Listener.onPlaybackSuppressionReasonChanged(int)
-
isPlaying
boolean isPlaying()
Deprecated.Returns whether the player is playing, i.e.getCurrentPosition()
is advancing.If
false
, then at least one of the following is true:- The
playback state
is notready
. - There is no
intention to play
. - Playback is
suppressed for other reasons
.
- Returns:
- Whether the player is playing.
- See Also:
Player.Listener.onIsPlayingChanged(boolean)
- The
-
getPlayerError
@Nullable PlaybackException getPlayerError()
Deprecated.Returns the error that caused playback to fail. This is the same error that will have been reported viaPlayer.Listener.onPlayerError(PlaybackException)
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
ifgetPlaybackState()
is notSTATE_IDLE
.- Returns:
- The error, or
null
. - See Also:
Player.Listener.onPlayerError(PlaybackException)
-
play
void play()
Deprecated.Resumes playback as soon asgetPlaybackState()
==STATE_READY
. Equivalent tosetPlayWhenReady(true)
.This method must only be called if
COMMAND_PLAY_PAUSE
is available.
-
pause
void pause()
Deprecated.Pauses playback. Equivalent tosetPlayWhenReady(false)
.This method must only be called if
COMMAND_PLAY_PAUSE
is available.
-
setPlayWhenReady
void setPlayWhenReady(boolean playWhenReady)
Deprecated.Sets whether playback should proceed whengetPlaybackState()
==STATE_READY
.If the player is already in the ready state then this method pauses and resumes playback.
This method must only be called if
COMMAND_PLAY_PAUSE
is available.- Parameters:
playWhenReady
- Whether playback should proceed when ready.
-
getPlayWhenReady
boolean getPlayWhenReady()
Deprecated.Whether playback will proceed whengetPlaybackState()
==STATE_READY
.- Returns:
- Whether playback will proceed when ready.
- See Also:
Player.Listener.onPlayWhenReadyChanged(boolean, int)
-
setRepeatMode
void setRepeatMode(@RepeatMode @com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
Deprecated.Sets thePlayer.RepeatMode
to be used for playback.This method must only be called if
COMMAND_SET_REPEAT_MODE
is available.- Parameters:
repeatMode
- The repeat mode.
-
getRepeatMode
@RepeatMode @com.google.android.exoplayer2.Player.RepeatMode int getRepeatMode()
Deprecated.Returns the currentPlayer.RepeatMode
used for playback.- Returns:
- The current repeat mode.
- See Also:
Player.Listener.onRepeatModeChanged(int)
-
setShuffleModeEnabled
void setShuffleModeEnabled(boolean shuffleModeEnabled)
Deprecated.Sets whether shuffling of media items is enabled.This method must only be called if
COMMAND_SET_SHUFFLE_MODE
is available.- Parameters:
shuffleModeEnabled
- Whether shuffling is enabled.
-
getShuffleModeEnabled
boolean getShuffleModeEnabled()
Deprecated.Returns whether shuffling of media items is enabled.
-
isLoading
boolean isLoading()
Deprecated.Whether the player is currently loading the source.- Returns:
- Whether the player is currently loading the source.
- See Also:
Player.Listener.onIsLoadingChanged(boolean)
-
seekToDefaultPosition
void seekToDefaultPosition()
Deprecated.Seeks to the default position associated with the currentMediaItem
. The position can depend on the type of media being played. For live streams it will typically be the live edge. For other streams it will typically be the start.This method must only be called if
COMMAND_SEEK_TO_DEFAULT_POSITION
is available.
-
seekToDefaultPosition
void seekToDefaultPosition(int mediaItemIndex)
Deprecated.Seeks to the default position associated with the specifiedMediaItem
. The position can depend on the type of media being played. For live streams it will typically be the live edge. For other streams it will typically be the start.This method must only be called if
COMMAND_SEEK_TO_MEDIA_ITEM
is available.- Parameters:
mediaItemIndex
- The index of theMediaItem
whose associated default position should be seeked to. If the index is larger than the size of the playlist, the request is ignored.
-
seekTo
void seekTo(long positionMs)
Deprecated.Seeks to a position specified in milliseconds in the currentMediaItem
.This method must only be called if
COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM
is available.- Parameters:
positionMs
- The seek position in the currentMediaItem
, orC.TIME_UNSET
to seek to the media item's default position.
-
seekTo
void seekTo(int mediaItemIndex, long positionMs)
Deprecated.Seeks to a position specified in milliseconds in the specifiedMediaItem
.This method must only be called if
COMMAND_SEEK_TO_MEDIA_ITEM
is available.- Parameters:
mediaItemIndex
- The index of theMediaItem
. If the index is larger than the size of the playlist, the request is ignored.positionMs
- The seek position in the specifiedMediaItem
, orC.TIME_UNSET
to seek to the media item's default position.
-
getSeekBackIncrement
long getSeekBackIncrement()
Deprecated.Returns theseekBack()
increment.- Returns:
- The seek back increment, in milliseconds.
- See Also:
Player.Listener.onSeekBackIncrementChanged(long)
-
seekBack
void seekBack()
Deprecated.Seeks back in the currentMediaItem
bygetSeekBackIncrement()
milliseconds.This method must only be called if
COMMAND_SEEK_BACK
is available.
-
getSeekForwardIncrement
long getSeekForwardIncrement()
Deprecated.Returns theseekForward()
increment.- Returns:
- The seek forward increment, in milliseconds.
- See Also:
Player.Listener.onSeekForwardIncrementChanged(long)
-
seekForward
void seekForward()
Deprecated.Seeks forward in the currentMediaItem
bygetSeekForwardIncrement()
milliseconds.This method must only be called if
COMMAND_SEEK_FORWARD
is available.
-
hasPrevious
@Deprecated boolean hasPrevious()
Deprecated.UsehasPreviousMediaItem()
instead.
-
hasPreviousWindow
@Deprecated boolean hasPreviousWindow()
Deprecated.UsehasPreviousMediaItem()
instead.
-
hasPreviousMediaItem
boolean hasPreviousMediaItem()
Deprecated.Returns whether a previous media item exists, which may depend on the current repeat mode and whether shuffle mode is enabled.Note: When the repeat mode is
REPEAT_MODE_ONE
, this method behaves the same as when the current repeat mode isREPEAT_MODE_OFF
. SeeREPEAT_MODE_ONE
for more details.This method must only be called if
COMMAND_GET_TIMELINE
is available.
-
previous
@Deprecated void previous()
Deprecated.UseseekToPreviousMediaItem()
instead.
-
seekToPreviousWindow
@Deprecated void seekToPreviousWindow()
Deprecated.UseseekToPreviousMediaItem()
instead.
-
seekToPreviousMediaItem
void seekToPreviousMediaItem()
Deprecated.Seeks to the default position of the previousMediaItem
, which may depend on the current repeat mode and whether shuffle mode is enabled. Does nothing ifhasPreviousMediaItem()
isfalse
.Note: When the repeat mode is
REPEAT_MODE_ONE
, this method behaves the same as when the current repeat mode isREPEAT_MODE_OFF
. SeeREPEAT_MODE_ONE
for more details.This method must only be called if
COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
is available.
-
getMaxSeekToPreviousPosition
long getMaxSeekToPreviousPosition()
Deprecated.Returns the maximum position for whichseekToPrevious()
seeks to the previousMediaItem
, in milliseconds.- Returns:
- The maximum seek to previous position, in milliseconds.
- See Also:
Player.Listener.onMaxSeekToPreviousPositionChanged(long)
-
seekToPrevious
void seekToPrevious()
Deprecated.Seeks to an earlier position in the current or previousMediaItem
(if available). More precisely:- If the timeline is empty or seeking is not possible, does nothing.
- Otherwise, if the current
MediaItem
isisCurrentMediaItemLive()
live} andunseekable
, then:- If
a previous media item exists
, seeks to the default position of the previous media item. - Otherwise, does nothing.
- If
- Otherwise, if
a previous media item exists
and thecurrent position
is less thangetMaxSeekToPreviousPosition()
, seeks to the default position of the previousMediaItem
. - Otherwise, seeks to 0 in the current
MediaItem
.
This method must only be called if
COMMAND_SEEK_TO_PREVIOUS
is available.
-
hasNext
@Deprecated boolean hasNext()
Deprecated.UsehasNextMediaItem()
instead.
-
hasNextWindow
@Deprecated boolean hasNextWindow()
Deprecated.UsehasNextMediaItem()
instead.
-
hasNextMediaItem
boolean hasNextMediaItem()
Deprecated.Returns whether a nextMediaItem
exists, which may depend on the current repeat mode and whether shuffle mode is enabled.Note: When the repeat mode is
REPEAT_MODE_ONE
, this method behaves the same as when the current repeat mode isREPEAT_MODE_OFF
. SeeREPEAT_MODE_ONE
for more details.This method must only be called if
COMMAND_GET_TIMELINE
is available.
-
next
@Deprecated void next()
Deprecated.UseseekToNextMediaItem()
instead.
-
seekToNextWindow
@Deprecated void seekToNextWindow()
Deprecated.UseseekToNextMediaItem()
instead.
-
seekToNextMediaItem
void seekToNextMediaItem()
Deprecated.Seeks to the default position of the nextMediaItem
, which may depend on the current repeat mode and whether shuffle mode is enabled. Does nothing ifhasNextMediaItem()
isfalse
.Note: When the repeat mode is
REPEAT_MODE_ONE
, this method behaves the same as when the current repeat mode isREPEAT_MODE_OFF
. SeeREPEAT_MODE_ONE
for more details.This method must only be called if
COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
is available.
-
seekToNext
void seekToNext()
Deprecated.Seeks to a later position in the current or nextMediaItem
(if available). More precisely:- If the timeline is empty or seeking is not possible, does nothing.
- Otherwise, if
a next media item exists
, seeks to the default position of the nextMediaItem
. - Otherwise, if the current
MediaItem
islive
and has not ended, seeks to the live edge of the currentMediaItem
. - Otherwise, does nothing.
This method must only be called if
COMMAND_SEEK_TO_NEXT
is available.
-
setPlaybackParameters
void setPlaybackParameters(PlaybackParameters playbackParameters)
Deprecated.Attempts to set the playback parameters. PassingPlaybackParameters.DEFAULT
resets the player to the default, which means there is no speed or pitch adjustment.Playback parameters changes may cause the player to buffer.
Player.Listener.onPlaybackParametersChanged(PlaybackParameters)
will be called whenever the currently active playback parameters change.This method must only be called if
COMMAND_SET_SPEED_AND_PITCH
is available.- Parameters:
playbackParameters
- The playback parameters.
-
setPlaybackSpeed
void setPlaybackSpeed(@FloatRange(from=0.0,fromInclusive=false) float speed)
Deprecated.Changes the rate at which playback occurs. The pitch is not changed.This is equivalent to
setPlaybackParameters(getPlaybackParameters().withSpeed(speed))
.This method must only be called if
COMMAND_SET_SPEED_AND_PITCH
is available.- Parameters:
speed
- The linear factor by which playback will be sped up. Must be higher than 0. 1 is normal speed, 2 is twice as fast, 0.5 is half normal speed.
-
getPlaybackParameters
PlaybackParameters getPlaybackParameters()
Deprecated.Returns the currently active playback parameters.
-
stop
void stop()
Deprecated.Stops playback without resetting the playlist. Usepause()
rather than this method if the intention is to pause playback.Calling this method will cause the playback state to transition to
STATE_IDLE
and the player will release the loaded media and resources required for playback. The player instance can still be used by callingprepare()
again, andrelease()
must still be called on the player if it's no longer required.Calling this method does not clear the playlist, reset the playback position or the playback error.
This method must only be called if
COMMAND_STOP
is available.
-
release
void release()
Deprecated.Releases the player. This method must be called when the player is no longer required. The player must not be used after calling this method.This method must only be called if
COMMAND_RELEASE
is available.
-
getCurrentTracks
Tracks getCurrentTracks()
Deprecated.Returns the current tracks.This method must only be called if
COMMAND_GET_TRACKS
is available.- See Also:
Player.Listener.onTracksChanged(Tracks)
-
getTrackSelectionParameters
TrackSelectionParameters getTrackSelectionParameters()
Deprecated.Returns the parameters constraining the track selection.- See Also:
}
-
setTrackSelectionParameters
void setTrackSelectionParameters(TrackSelectionParameters parameters)
Deprecated.Sets the parameters constraining the track selection.Unsupported parameters will be silently ignored.
Use
getTrackSelectionParameters()
to retrieve the current parameters. For example, the following snippet restricts video to SD whilst keep other track selection parameters unchanged:player.setTrackSelectionParameters( player.getTrackSelectionParameters() .buildUpon() .setMaxVideoSizeSd() .build())
This method must only be called if
COMMAND_SET_TRACK_SELECTION_PARAMETERS
is available.
-
getMediaMetadata
MediaMetadata getMediaMetadata()
Deprecated.Returns the current combinedMediaMetadata
, orMediaMetadata.EMPTY
if not supported.This
MediaMetadata
is a combination of theMediaItem metadata
, the static metadata in the media'sFormat
, and any timed metadata that has been parsed from the media and output viaPlayer.Listener.onMetadata(Metadata)
. If a field is populated in theMediaItem.mediaMetadata
, it will be prioritised above the same field coming from static or timed metadata.This method must only be called if
COMMAND_GET_METADATA
is available.
-
getPlaylistMetadata
MediaMetadata getPlaylistMetadata()
Deprecated.Returns the playlistMediaMetadata
, as set bysetPlaylistMetadata(MediaMetadata)
, orMediaMetadata.EMPTY
if not supported.This method must only be called if
COMMAND_GET_METADATA
is available.
-
setPlaylistMetadata
void setPlaylistMetadata(MediaMetadata mediaMetadata)
Deprecated.Sets the playlistMediaMetadata
.This method must only be called if
COMMAND_SET_PLAYLIST_METADATA
is available.
-
getCurrentManifest
@Nullable Object getCurrentManifest()
Deprecated.Returns the current manifest. The type depends on the type of media being played. May be null.
-
getCurrentTimeline
Timeline getCurrentTimeline()
Deprecated.Returns the currentTimeline
. Never null, but may be empty.This method must only be called if
COMMAND_GET_TIMELINE
is available.
-
getCurrentPeriodIndex
int getCurrentPeriodIndex()
Deprecated.Returns the index of the period currently being played.This method must only be called if
COMMAND_GET_TIMELINE
is available.
-
getCurrentWindowIndex
@Deprecated int getCurrentWindowIndex()
Deprecated.UsegetCurrentMediaItemIndex()
instead.
-
getCurrentMediaItemIndex
int getCurrentMediaItemIndex()
Deprecated.Returns the index of the currentMediaItem
in thetimeline
, or the prospective index if thecurrent timeline
is empty.This method must only be called if
COMMAND_GET_TIMELINE
is available.
-
getNextWindowIndex
@Deprecated int getNextWindowIndex()
Deprecated.UsegetNextMediaItemIndex()
instead.
-
getNextMediaItemIndex
int getNextMediaItemIndex()
Deprecated.Returns the index of theMediaItem
that will be played ifseekToNextMediaItem()
is called, which may depend on the current repeat mode and whether shuffle mode is enabled. ReturnsC.INDEX_UNSET
ifhasNextMediaItem()
isfalse
.Note: When the repeat mode is
REPEAT_MODE_ONE
, this method behaves the same as when the current repeat mode isREPEAT_MODE_OFF
. SeeREPEAT_MODE_ONE
for more details.This method must only be called if
COMMAND_GET_TIMELINE
is available.
-
getPreviousWindowIndex
@Deprecated int getPreviousWindowIndex()
Deprecated.UsegetPreviousMediaItemIndex()
instead.
-
getPreviousMediaItemIndex
int getPreviousMediaItemIndex()
Deprecated.Returns the index of theMediaItem
that will be played ifseekToPreviousMediaItem()
is called, which may depend on the current repeat mode and whether shuffle mode is enabled. ReturnsC.INDEX_UNSET
ifhasPreviousMediaItem()
isfalse
.Note: When the repeat mode is
REPEAT_MODE_ONE
, this method behaves the same as when the current repeat mode isREPEAT_MODE_OFF
. SeeREPEAT_MODE_ONE
for more details.This method must only be called if
COMMAND_GET_TIMELINE
is available.
-
getCurrentMediaItem
@Nullable MediaItem getCurrentMediaItem()
Deprecated.Returns the currently playingMediaItem
. May be null if the timeline is empty.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.
-
getMediaItemCount
int getMediaItemCount()
Deprecated.Returns the number of media items in the playlist.This method must only be called if
COMMAND_GET_TIMELINE
is available.
-
getMediaItemAt
MediaItem getMediaItemAt(int index)
Deprecated.Returns theMediaItem
at the given index.This method must only be called if
COMMAND_GET_TIMELINE
is available.
-
getDuration
long getDuration()
Deprecated.Returns the duration of the current content or ad in milliseconds, orC.TIME_UNSET
if the duration is not known.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.
-
getCurrentPosition
long getCurrentPosition()
Deprecated.Returns the playback position in the current content or ad, in milliseconds, or the prospective position in milliseconds if thecurrent timeline
is empty.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.
-
getBufferedPosition
long getBufferedPosition()
Deprecated.Returns an estimate of the position in the current content or ad up to which data is buffered, in milliseconds.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.
-
getBufferedPercentage
@IntRange(from=0L, to=100L) int getBufferedPercentage()
Deprecated.Returns an estimate of the percentage in the current content or ad up to which data is buffered, or 0 if no estimate is available.
-
getTotalBufferedDuration
long getTotalBufferedDuration()
Deprecated.Returns an estimate of the total buffered duration from the current position, in milliseconds. This includes pre-buffered data for subsequent ads and media items.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.
-
isCurrentWindowDynamic
@Deprecated boolean isCurrentWindowDynamic()
Deprecated.UseisCurrentMediaItemDynamic()
instead.
-
isCurrentMediaItemDynamic
boolean isCurrentMediaItemDynamic()
Deprecated.Returns whether the currentMediaItem
is dynamic (may change when theTimeline
is updated), orfalse
if theTimeline
is empty.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.- See Also:
Timeline.Window.isDynamic
-
isCurrentWindowLive
@Deprecated boolean isCurrentWindowLive()
Deprecated.UseisCurrentMediaItemLive()
instead.
-
isCurrentMediaItemLive
boolean isCurrentMediaItemLive()
Deprecated.Returns whether the currentMediaItem
is live, orfalse
if theTimeline
is empty.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.- See Also:
Timeline.Window.isLive()
-
getCurrentLiveOffset
long getCurrentLiveOffset()
Deprecated.Returns the offset of the current playback position from the live edge in milliseconds, orC.TIME_UNSET
if the currentMediaItem
isCurrentMediaItemLive()
isn't live} or the offset is unknown.The offset is calculated as
currentTime - playbackPosition
, so should usually be positive.Note that this offset may rely on an accurate local time, so this method may return an incorrect value if the difference between system clock and server clock is unknown.
This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.
-
isCurrentWindowSeekable
@Deprecated boolean isCurrentWindowSeekable()
Deprecated.UseisCurrentMediaItemSeekable()
instead.
-
isCurrentMediaItemSeekable
boolean isCurrentMediaItemSeekable()
Deprecated.Returns whether the currentMediaItem
is seekable, orfalse
if theTimeline
is empty.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.- See Also:
Timeline.Window.isSeekable
-
isPlayingAd
boolean isPlayingAd()
Deprecated.Returns whether the player is currently playing an ad.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.
-
getCurrentAdGroupIndex
int getCurrentAdGroupIndex()
Deprecated.IfisPlayingAd()
returns true, returns the index of the ad group in the period currently being played. ReturnsC.INDEX_UNSET
otherwise.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.
-
getCurrentAdIndexInAdGroup
int getCurrentAdIndexInAdGroup()
Deprecated.IfisPlayingAd()
returns true, returns the index of the ad in its ad group. ReturnsC.INDEX_UNSET
otherwise.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.
-
getContentDuration
long getContentDuration()
Deprecated.IfisPlayingAd()
returnstrue
, returns the duration of the current content in milliseconds, orC.TIME_UNSET
if the duration is not known. If there is no ad playing, the returned duration is the same as that returned bygetDuration()
.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.
-
getContentPosition
long getContentPosition()
Deprecated.IfisPlayingAd()
returnstrue
, 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 bygetCurrentPosition()
.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.
-
getContentBufferedPosition
long getContentBufferedPosition()
Deprecated.IfisPlayingAd()
returnstrue
, returns an estimate of the content position in the current content up to which data is buffered, in milliseconds. If there is no ad playing, the returned position is the same as that returned bygetBufferedPosition()
.This method must only be called if
COMMAND_GET_CURRENT_MEDIA_ITEM
is available.
-
getAudioAttributes
AudioAttributes getAudioAttributes()
Deprecated.Returns the attributes for audio playback.This method must only be called if
COMMAND_GET_AUDIO_ATTRIBUTES
is available.
-
setVolume
void setVolume(@FloatRange(from=0.0,to=1.0) float volume)
Deprecated.Sets the audio volume, valid values are between 0 (silence) and 1 (unity gain, signal unchanged), inclusive.This method must only be called if
COMMAND_SET_VOLUME
is available.- Parameters:
volume
- Linear output gain to apply to all audio channels.
-
getVolume
@FloatRange(from=0.0, to=1.0) float getVolume()
Deprecated.Returns the audio volume, with 0 being silence and 1 being unity gain (signal unchanged).This method must only be called if
COMMAND_GET_VOLUME
is available.- Returns:
- The linear gain applied to all audio channels.
-
clearVideoSurface
void clearVideoSurface()
Deprecated.Clears anySurface
,SurfaceHolder
,SurfaceView
orTextureView
currently set on the player.This method must only be called if
COMMAND_SET_VIDEO_SURFACE
is available.
-
clearVideoSurface
void clearVideoSurface(@Nullable Surface surface)
Deprecated.Clears theSurface
onto which video is being rendered if it matches the one passed. Else does nothing.This method must only be called if
COMMAND_SET_VIDEO_SURFACE
is available.- Parameters:
surface
- The surface to clear.
-
setVideoSurface
void setVideoSurface(@Nullable Surface surface)
Deprecated.Sets theSurface
onto which video will be rendered. The caller is responsible for tracking the lifecycle of the surface, and must clear the surface by callingsetVideoSurface(null)
if the surface is destroyed.If the surface is held by a
SurfaceView
,TextureView
orSurfaceHolder
then it's recommended to usesetVideoSurfaceView(SurfaceView)
,setVideoTextureView(TextureView)
orsetVideoSurfaceHolder(SurfaceHolder)
rather than this method, since passing the holder allows the player to track the lifecycle of the surface automatically.This method must only be called if
COMMAND_SET_VIDEO_SURFACE
is available.- Parameters:
surface
- TheSurface
.
-
setVideoSurfaceHolder
void setVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder)
Deprecated.Sets theSurfaceHolder
that holds theSurface
onto which video will be rendered. The player will track the lifecycle of the surface automatically.The thread that calls the
SurfaceHolder.Callback
methods must be the thread associated withgetApplicationLooper()
.This method must only be called if
COMMAND_SET_VIDEO_SURFACE
is available.- Parameters:
surfaceHolder
- The surface holder.
-
clearVideoSurfaceHolder
void clearVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder)
Deprecated.Clears theSurfaceHolder
that holds theSurface
onto which video is being rendered if it matches the one passed. Else does nothing.This method must only be called if
COMMAND_SET_VIDEO_SURFACE
is available.- Parameters:
surfaceHolder
- The surface holder to clear.
-
setVideoSurfaceView
void setVideoSurfaceView(@Nullable SurfaceView surfaceView)
Deprecated.Sets theSurfaceView
onto which video will be rendered. The player will track the lifecycle of the surface automatically.The thread that calls the
SurfaceHolder.Callback
methods must be the thread associated withgetApplicationLooper()
.This method must only be called if
COMMAND_SET_VIDEO_SURFACE
is available.- Parameters:
surfaceView
- The surface view.
-
clearVideoSurfaceView
void clearVideoSurfaceView(@Nullable SurfaceView surfaceView)
Deprecated.Clears theSurfaceView
onto which video is being rendered if it matches the one passed. Else does nothing.This method must only be called if
COMMAND_SET_VIDEO_SURFACE
is available.- Parameters:
surfaceView
- The texture view to clear.
-
setVideoTextureView
void setVideoTextureView(@Nullable TextureView textureView)
Deprecated.Sets theTextureView
onto which video will be rendered. The player will track the lifecycle of the surface automatically.The thread that calls the
TextureView.SurfaceTextureListener
methods must be the thread associated withgetApplicationLooper()
.This method must only be called if
COMMAND_SET_VIDEO_SURFACE
is available.- Parameters:
textureView
- The texture view.
-
clearVideoTextureView
void clearVideoTextureView(@Nullable TextureView textureView)
Deprecated.Clears theTextureView
onto which video is being rendered if it matches the one passed. Else does nothing.This method must only be called if
COMMAND_SET_VIDEO_SURFACE
is available.- Parameters:
textureView
- The texture view to clear.
-
getVideoSize
VideoSize getVideoSize()
Deprecated.Gets the size of the video.The video's width and height are
0
if there is no supported video track or its size has not been determined yet.
-
getSurfaceSize
Size getSurfaceSize()
Deprecated.Gets the size of the surface on which the video is rendered.
-
getCurrentCues
CueGroup getCurrentCues()
Deprecated.Returns the currentCueGroup
.This method must only be called if
COMMAND_GET_TEXT
is available.
-
getDeviceInfo
DeviceInfo getDeviceInfo()
Deprecated.Gets the device information.
-
getDeviceVolume
@IntRange(from=0L) int getDeviceVolume()
Deprecated.Gets the current volume of the device.For devices with
local playback
, the volume returned by this method varies according to the currentstream type
. The stream type is determined byAudioAttributes.usage
which can be converted to stream type withUtil.getStreamTypeForAudioUsage(int)
.For devices with
remote playback
, the volume of the remote device is returned.This method must only be called if
COMMAND_GET_DEVICE_VOLUME
is available.
-
isDeviceMuted
boolean isDeviceMuted()
Deprecated.Gets whether the device is muted or not.This method must only be called if
COMMAND_GET_DEVICE_VOLUME
is available.
-
setDeviceVolume
@Deprecated void setDeviceVolume(@IntRange(from=0L) int volume)
Deprecated.UsesetDeviceVolume(int, int)
instead.
-
setDeviceVolume
void setDeviceVolume(@IntRange(from=0L) int volume, int flags)
Deprecated.Sets the volume of the device with volume flags.This method must only be called if
COMMAND_SET_DEVICE_VOLUME_WITH_FLAGS
is available.- Parameters:
volume
- The volume to set.flags
- Either 0 or a bitwise combination of one or moreC.VolumeFlags
.
-
increaseDeviceVolume
@Deprecated void increaseDeviceVolume()
Deprecated.UseincreaseDeviceVolume(int)
instead.
-
increaseDeviceVolume
void increaseDeviceVolume(@com.google.android.exoplayer2.C.VolumeFlags int flags)
Deprecated.Increases the volume of the device.The
getDeviceVolume()
device volume cannot be increased aboveDeviceInfo.maxVolume
, if defined.This method must only be called if
COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS
is available.- Parameters:
flags
- Either 0 or a bitwise combination of one or moreC.VolumeFlags
.
-
decreaseDeviceVolume
@Deprecated void decreaseDeviceVolume()
Deprecated.UsedecreaseDeviceVolume(int)
instead.
-
decreaseDeviceVolume
void decreaseDeviceVolume(@com.google.android.exoplayer2.C.VolumeFlags int flags)
Deprecated.Decreases the volume of the device.The
getDeviceVolume()
device volume cannot be decreased belowDeviceInfo.minVolume
.This method must only be called if
COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS
is available.- Parameters:
flags
- Either 0 or a bitwise combination of one or moreC.VolumeFlags
.
-
setDeviceMuted
@Deprecated void setDeviceMuted(boolean muted)
Deprecated.UsesetDeviceMuted(boolean, int)
instead.
-
setDeviceMuted
void setDeviceMuted(boolean muted, @com.google.android.exoplayer2.C.VolumeFlags int flags)
Deprecated.Sets the mute state of the device.This method must only be called if
COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS
is available.- Parameters:
muted
- Whether to set the device to be muted or notflags
- Either 0 or a bitwise combination of one or moreC.VolumeFlags
.
-
-