Class ForwardingPlayer
- java.lang.Object
-
- com.google.android.exoplayer2.ForwardingPlayer
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.Player
Player.Command, Player.Commands, Player.DiscontinuityReason, Player.Event, Player.EventListener, Player.Events, Player.Listener, Player.MediaItemTransitionReason, Player.PlaybackSuppressionReason, Player.PlayWhenReadyChangeReason, Player.PositionInfo, Player.RepeatMode, Player.State, Player.TimelineChangeReason
-
-
Field Summary
-
Fields inherited from interface com.google.android.exoplayer2.Player
COMMAND_ADJUST_DEVICE_VOLUME, COMMAND_CHANGE_MEDIA_ITEMS, COMMAND_GET_AUDIO_ATTRIBUTES, COMMAND_GET_CURRENT_MEDIA_ITEM, COMMAND_GET_DEVICE_VOLUME, COMMAND_GET_MEDIA_ITEMS_METADATA, COMMAND_GET_TEXT, COMMAND_GET_TIMELINE, COMMAND_GET_TRACK_INFOS, COMMAND_GET_VOLUME, COMMAND_INVALID, COMMAND_PLAY_PAUSE, COMMAND_PREPARE, COMMAND_SEEK_BACK, COMMAND_SEEK_FORWARD, COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM, COMMAND_SEEK_IN_CURRENT_WINDOW, COMMAND_SEEK_TO_DEFAULT_POSITION, COMMAND_SEEK_TO_MEDIA_ITEM, COMMAND_SEEK_TO_NEXT, COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, COMMAND_SEEK_TO_NEXT_WINDOW, COMMAND_SEEK_TO_PREVIOUS, COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, COMMAND_SEEK_TO_PREVIOUS_WINDOW, COMMAND_SEEK_TO_WINDOW, COMMAND_SET_DEVICE_VOLUME, COMMAND_SET_MEDIA_ITEMS_METADATA, COMMAND_SET_REPEAT_MODE, COMMAND_SET_SHUFFLE_MODE, COMMAND_SET_SPEED_AND_PITCH, COMMAND_SET_TRACK_SELECTION_PARAMETERS, COMMAND_SET_VIDEO_SURFACE, COMMAND_SET_VOLUME, COMMAND_STOP, DISCONTINUITY_REASON_AUTO_TRANSITION, DISCONTINUITY_REASON_INTERNAL, DISCONTINUITY_REASON_REMOVE, DISCONTINUITY_REASON_SEEK, DISCONTINUITY_REASON_SEEK_ADJUSTMENT, DISCONTINUITY_REASON_SKIP, EVENT_AVAILABLE_COMMANDS_CHANGED, EVENT_IS_LOADING_CHANGED, EVENT_IS_PLAYING_CHANGED, EVENT_MAX_SEEK_TO_PREVIOUS_POSITION_CHANGED, EVENT_MEDIA_ITEM_TRANSITION, EVENT_MEDIA_METADATA_CHANGED, EVENT_PLAY_WHEN_READY_CHANGED, EVENT_PLAYBACK_PARAMETERS_CHANGED, EVENT_PLAYBACK_STATE_CHANGED, EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED, EVENT_PLAYER_ERROR, EVENT_PLAYLIST_METADATA_CHANGED, EVENT_POSITION_DISCONTINUITY, EVENT_REPEAT_MODE_CHANGED, EVENT_SEEK_BACK_INCREMENT_CHANGED, EVENT_SEEK_FORWARD_INCREMENT_CHANGED, EVENT_SHUFFLE_MODE_ENABLED_CHANGED, EVENT_TIMELINE_CHANGED, EVENT_TRACK_SELECTION_PARAMETERS_CHANGED, EVENT_TRACKS_CHANGED, MEDIA_ITEM_TRANSITION_REASON_AUTO, MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED, MEDIA_ITEM_TRANSITION_REASON_REPEAT, MEDIA_ITEM_TRANSITION_REASON_SEEK, PLAY_WHEN_READY_CHANGE_REASON_AUDIO_BECOMING_NOISY, PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS, PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM, PLAY_WHEN_READY_CHANGE_REASON_REMOTE, PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST, PLAYBACK_SUPPRESSION_REASON_NONE, PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS, REPEAT_MODE_ALL, REPEAT_MODE_OFF, REPEAT_MODE_ONE, STATE_BUFFERING, STATE_ENDED, STATE_IDLE, STATE_READY, TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, TIMELINE_CHANGE_REASON_SOURCE_UPDATE
-
-
Constructor Summary
Constructors Constructor Description ForwardingPlayer(Player player)Creates a new instance that forwards all operations toplayer.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddListener(Player.Listener listener)Deprecated.voidaddMediaItem(int index, MediaItem mediaItem)Adds a media item at the given index of the playlist.voidaddMediaItem(MediaItem mediaItem)Adds a media item to the end of the playlist.voidaddMediaItems(int index, List<MediaItem> mediaItems)Adds a list of media items at the given index of the playlist.voidaddMediaItems(List<MediaItem> mediaItems)Adds a list of media items to the end of the playlist.booleancanAdvertiseSession()Returns whether the player can be used to advertise a media session.voidclearMediaItems()Clears the playlist.voidclearVideoSurface()voidclearVideoSurface(Surface surface)Clears theSurfaceonto which video is being rendered if it matches the one passed.voidclearVideoSurfaceHolder(SurfaceHolder surfaceHolder)Clears theSurfaceHolderthat holds theSurfaceonto which video is being rendered if it matches the one passed.voidclearVideoSurfaceView(SurfaceView surfaceView)Clears theSurfaceViewonto which video is being rendered if it matches the one passed.voidclearVideoTextureView(TextureView textureView)Clears theTextureViewonto which video is being rendered if it matches the one passed.voiddecreaseDeviceVolume()Decreases the volume of the device.LoopergetApplicationLooper()Deprecated.AudioAttributesgetAudioAttributes()Returns the attributes for audio playback.Player.CommandsgetAvailableCommands()Returns the player's currently availablePlayer.Commands.intgetBufferedPercentage()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.longgetBufferedPosition()Returns an estimate of the position in the current content or ad up to which data is buffered, in milliseconds.longgetContentBufferedPosition()IfPlayer.isPlayingAd()returnstrue, returns an estimate of the content position in the current content up to which data is buffered, in milliseconds.longgetContentDuration()IfPlayer.isPlayingAd()returnstrue, returns the duration of the current content in milliseconds, orC.TIME_UNSETif the duration is not known.longgetContentPosition()IfPlayer.isPlayingAd()returnstrue, returns the content position that will be played once all ads in the ad group have finished playing, in milliseconds.intgetCurrentAdGroupIndex()IfPlayer.isPlayingAd()returns true, returns the index of the ad group in the period currently being played.intgetCurrentAdIndexInAdGroup()IfPlayer.isPlayingAd()returns true, returns the index of the ad in its ad group.List<Cue>getCurrentCues()Returns the currentCues.longgetCurrentLiveOffset()Returns the offset of the current playback position from the live edge in milliseconds, orC.TIME_UNSETif the currentMediaItemPlayer.isCurrentMediaItemLive()isn't live} or the offset is unknown.ObjectgetCurrentManifest()Returns the current manifest.MediaItemgetCurrentMediaItem()Returns the currently playingMediaItem.intgetCurrentMediaItemIndex()Returns the index of the currentMediaItemin thetimeline, or the prospective index if thecurrent timelineis empty.intgetCurrentPeriodIndex()Returns the index of the period currently being played.longgetCurrentPosition()Returns the playback position in the current content or ad, in milliseconds, or the prospective position in milliseconds if thecurrent timelineis empty.TimelinegetCurrentTimeline()Returns the currentTimeline.TrackGroupArraygetCurrentTrackGroups()Returns the available track groups.TrackSelectionArraygetCurrentTrackSelections()Returns the current track selections.TracksInfogetCurrentTracksInfo()Returns the available tracks, as well as the tracks' support, type, and selection status.intgetCurrentWindowIndex()Deprecated.DeviceInfogetDeviceInfo()Gets the device information.intgetDeviceVolume()Gets the current volume of the device.longgetDuration()Returns the duration of the current content or ad in milliseconds, orC.TIME_UNSETif the duration is not known.longgetMaxSeekToPreviousPosition()Returns the maximum position for whichPlayer.seekToPrevious()seeks to the previousMediaItem, in milliseconds.MediaItemgetMediaItemAt(int index)Returns theMediaItemat the given index.intgetMediaItemCount()Returns the number ofmedia itemsin the playlist.MediaMetadatagetMediaMetadata()Returns the current combinedMediaMetadata, orMediaMetadata.EMPTYif not supported.intgetNextMediaItemIndex()Returns the index of theMediaItemthat will be played ifPlayer.seekToNextMediaItem()is called, which may depend on the current repeat mode and whether shuffle mode is enabled.intgetNextWindowIndex()Deprecated.PlaybackParametersgetPlaybackParameters()Returns the currently active playback parameters.intgetPlaybackState()Returns the currentplayback stateof the player.intgetPlaybackSuppressionReason()Returns the reason why playback is suppressed even thoughPlayer.getPlayWhenReady()istrue, orPlayer.PLAYBACK_SUPPRESSION_REASON_NONEif playback is not suppressed.PlaybackExceptiongetPlayerError()Returns the error that caused playback to fail.MediaMetadatagetPlaylistMetadata()Returns the playlistMediaMetadata, as set byPlayer.setPlaylistMetadata(MediaMetadata), orMediaMetadata.EMPTYif not supported.booleangetPlayWhenReady()Whether playback will proceed whenPlayer.getPlaybackState()==Player.STATE_READY.intgetPreviousMediaItemIndex()Returns the index of theMediaItemthat will be played ifPlayer.seekToPreviousMediaItem()is called, which may depend on the current repeat mode and whether shuffle mode is enabled.intgetPreviousWindowIndex()Deprecated.intgetRepeatMode()Returns the currentPlayer.RepeatModeused for playback.longgetSeekBackIncrement()Returns thePlayer.seekBack()increment.longgetSeekForwardIncrement()Returns thePlayer.seekForward()increment.booleangetShuffleModeEnabled()Returns whether shuffling of media items is enabled.longgetTotalBufferedDuration()Returns an estimate of the total buffered duration from the current position, in milliseconds.TrackSelectionParametersgetTrackSelectionParameters()Returns the parameters constraining the track selection.VideoSizegetVideoSize()Gets the size of the video.floatgetVolume()Returns the audio volume, with 0 being silence and 1 being unity gain (signal unchanged).PlayergetWrappedPlayer()Returns thePlayerto which operations are forwarded.booleanhasNext()Deprecated.booleanhasNextMediaItem()Returns whether a nextMediaItemexists, which may depend on the current repeat mode and whether shuffle mode is enabled.booleanhasNextWindow()Deprecated.booleanhasPrevious()Deprecated.booleanhasPreviousMediaItem()Returns whether a previous media item exists, which may depend on the current repeat mode and whether shuffle mode is enabled.booleanhasPreviousWindow()Deprecated.voidincreaseDeviceVolume()Increases the volume of the device.booleanisCommandAvailable(@com.google.android.exoplayer2.Player.Command int command)Returns whether the providedPlayer.Commandis available.booleanisCurrentMediaItemDynamic()booleanisCurrentMediaItemLive()booleanisCurrentMediaItemSeekable()booleanisCurrentWindowDynamic()Deprecated.booleanisCurrentWindowLive()Deprecated.booleanisCurrentWindowSeekable()Deprecated.booleanisDeviceMuted()Gets whether the device is muted or not.booleanisLoading()Whether the player is currently loading the source.booleanisPlaying()Returns whether the player is playing, i.e.booleanisPlayingAd()Returns whether the player is currently playing an ad.voidmoveMediaItem(int currentIndex, int newIndex)Moves the media item at the current index to the new index.voidmoveMediaItems(int fromIndex, int toIndex, int newIndex)Moves the media item range to the new index.voidnext()Deprecated.voidpause()Pauses playback.voidplay()Resumes playback as soon asPlayer.getPlaybackState()==Player.STATE_READY.voidprepare()Prepares the player.voidprevious()Deprecated.voidrelease()Releases the player.voidremoveListener(Player.Listener listener)Unregister a listener registered throughPlayer.addListener(Listener).voidremoveMediaItem(int index)Removes the media item at the given index of the playlist.voidremoveMediaItems(int fromIndex, int toIndex)Removes a range of media items from the playlist.voidseekBack()Seeks back in the currentMediaItembyPlayer.getSeekBackIncrement()milliseconds.voidseekForward()Seeks forward in the currentMediaItembyPlayer.getSeekForwardIncrement()milliseconds.voidseekTo(int mediaItemIndex, long positionMs)Seeks to a position specified in milliseconds in the specifiedMediaItem.voidseekTo(long positionMs)Seeks to a position specified in milliseconds in the currentMediaItem.voidseekToDefaultPosition()Seeks to the default position associated with the currentMediaItem.voidseekToDefaultPosition(int mediaItemIndex)Seeks to the default position associated with the specifiedMediaItem.voidseekToNext()Seeks to a later position in the current or nextMediaItem(if available).voidseekToNextMediaItem()Seeks to the default position of the nextMediaItem, which may depend on the current repeat mode and whether shuffle mode is enabled.voidseekToNextWindow()Deprecated.voidseekToPrevious()Seeks to an earlier position in the current or previousMediaItem(if available).voidseekToPreviousMediaItem()Seeks to the default position of the previousMediaItem, which may depend on the current repeat mode and whether shuffle mode is enabled.voidseekToPreviousWindow()Deprecated.voidsetDeviceMuted(boolean muted)Sets the mute state of the device.voidsetDeviceVolume(int volume)Sets the volume of the device.voidsetMediaItem(MediaItem mediaItem)Clears the playlist, adds the specifiedMediaItemand resets the position to the default position.voidsetMediaItem(MediaItem mediaItem, boolean resetPosition)Clears the playlist and adds the specifiedMediaItem.voidsetMediaItem(MediaItem mediaItem, long startPositionMs)Clears the playlist and adds the specifiedMediaItem.voidsetMediaItems(List<MediaItem> mediaItems)Clears the playlist, adds the specifiedMediaItemsand resets the position to the default position.voidsetMediaItems(List<MediaItem> mediaItems, boolean resetPosition)Clears the playlist and adds the specifiedMediaItems.voidsetMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs)Clears the playlist and adds the specifiedMediaItems.voidsetPlaybackParameters(PlaybackParameters playbackParameters)Attempts to set the playback parameters.voidsetPlaybackSpeed(float speed)Changes the rate at which playback occurs.voidsetPlaylistMetadata(MediaMetadata mediaMetadata)Sets the playlistMediaMetadata.voidsetPlayWhenReady(boolean playWhenReady)Sets whether playback should proceed whenPlayer.getPlaybackState()==Player.STATE_READY.voidsetRepeatMode(@com.google.android.exoplayer2.Player.RepeatMode int repeatMode)Sets thePlayer.RepeatModeto be used for playback.voidsetShuffleModeEnabled(boolean shuffleModeEnabled)Sets whether shuffling of media items is enabled.voidsetTrackSelectionParameters(TrackSelectionParameters parameters)Sets the parameters constraining the track selection.voidsetVideoSurface(Surface surface)Sets theSurfaceonto which video will be rendered.voidsetVideoSurfaceHolder(SurfaceHolder surfaceHolder)Sets theSurfaceHolderthat holds theSurfaceonto which video will be rendered.voidsetVideoSurfaceView(SurfaceView surfaceView)Sets theSurfaceViewonto which video will be rendered.voidsetVideoTextureView(TextureView textureView)Sets theTextureViewonto which video will be rendered.voidsetVolume(float volume)Sets the audio volume, valid values are between 0 (silence) and 1 (unity gain, signal unchanged), inclusive.voidstop()Stops playback without resetting the playlist.voidstop(boolean reset)Deprecated.
-
-
-
Constructor Detail
-
ForwardingPlayer
public ForwardingPlayer(Player player)
Creates a new instance that forwards all operations toplayer.
-
-
Method Detail
-
getApplicationLooper
@Deprecated public Looper getApplicationLooper()
Deprecated.Description copied from interface:PlayerReturns theLooperassociated with the application thread that's used to access the player and on which player events are received.- Specified by:
getApplicationLooperin interfacePlayer
-
addListener
@Deprecated public void addListener(Player.Listener listener)
Deprecated.Description copied from interface:PlayerRegisters a listener to receive all events from the player.The listener's methods will be called on the thread associated with
Player.getApplicationLooper().- Specified by:
addListenerin interfacePlayer- Parameters:
listener- The listener to register.
-
removeListener
public void removeListener(Player.Listener listener)
Description copied from interface:PlayerUnregister a listener registered throughPlayer.addListener(Listener). The listener will no longer receive events.- Specified by:
removeListenerin interfacePlayer- Parameters:
listener- The listener to unregister.
-
setMediaItems
public void setMediaItems(List<MediaItem> mediaItems)
Description copied from interface:PlayerClears the playlist, adds the specifiedMediaItemsand resets the position to the default position.- Specified by:
setMediaItemsin interfacePlayer- Parameters:
mediaItems- The newMediaItems.
-
setMediaItems
public void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition)
Description copied from interface:PlayerClears the playlist and adds the specifiedMediaItems.- Specified by:
setMediaItemsin interfacePlayer- Parameters:
mediaItems- The newMediaItems.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 byPlayer.getCurrentMediaItemIndex()andPlayer.getCurrentPosition().
-
setMediaItems
public void setMediaItems(List<MediaItem> mediaItems, int startIndex, long startPositionMs)
Description copied from interface:PlayerClears the playlist and adds the specifiedMediaItems.- Specified by:
setMediaItemsin interfacePlayer- Parameters:
mediaItems- The newMediaItems.startIndex- TheMediaItemindex to start playback from. IfC.INDEX_UNSETis passed, the current position is not reset.startPositionMs- The position in milliseconds to start playback from. IfC.TIME_UNSETis passed, the default position of the givenMediaItemis used. In any case, ifstartIndexis set toC.INDEX_UNSET, this parameter is ignored and the position is not reset at all.
-
setMediaItem
public void setMediaItem(MediaItem mediaItem)
Description copied from interface:PlayerClears the playlist, adds the specifiedMediaItemand resets the position to the default position.- Specified by:
setMediaItemin interfacePlayer- Parameters:
mediaItem- The newMediaItem.
-
setMediaItem
public void setMediaItem(MediaItem mediaItem, long startPositionMs)
Description copied from interface:PlayerClears the playlist and adds the specifiedMediaItem.- Specified by:
setMediaItemin interfacePlayer- Parameters:
mediaItem- The newMediaItem.startPositionMs- The position in milliseconds to start playback from.
-
setMediaItem
public void setMediaItem(MediaItem mediaItem, boolean resetPosition)
Description copied from interface:PlayerClears the playlist and adds the specifiedMediaItem.- Specified by:
setMediaItemin interfacePlayer- 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 byPlayer.getCurrentMediaItemIndex()andPlayer.getCurrentPosition().
-
addMediaItem
public void addMediaItem(MediaItem mediaItem)
Description copied from interface:PlayerAdds a media item to the end of the playlist.- Specified by:
addMediaItemin interfacePlayer- Parameters:
mediaItem- TheMediaItemto add.
-
addMediaItem
public void addMediaItem(int index, MediaItem mediaItem)Description copied from interface:PlayerAdds a media item at the given index of the playlist.- Specified by:
addMediaItemin interfacePlayer- 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- TheMediaItemto add.
-
addMediaItems
public void addMediaItems(List<MediaItem> mediaItems)
Description copied from interface:PlayerAdds a list of media items to the end of the playlist.- Specified by:
addMediaItemsin interfacePlayer- Parameters:
mediaItems- TheMediaItemsto add.
-
addMediaItems
public void addMediaItems(int index, List<MediaItem> mediaItems)Description copied from interface:PlayerAdds a list of media items at the given index of the playlist.- Specified by:
addMediaItemsin interfacePlayer- 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- TheMediaItemsto add.
-
moveMediaItem
public void moveMediaItem(int currentIndex, int newIndex)Description copied from interface:PlayerMoves the media item at the current index to the new index.- Specified by:
moveMediaItemin interfacePlayer- Parameters:
currentIndex- The current index of the media item to move.newIndex- The new index of the media item. If the new index is larger than the size of the playlist the item is moved to the end of the playlist.
-
moveMediaItems
public void moveMediaItems(int fromIndex, int toIndex, int newIndex)Description copied from interface:PlayerMoves the media item range to the new index.- Specified by:
moveMediaItemsin interfacePlayer- Parameters:
fromIndex- The start of the range to move.toIndex- The first item not to be included in the range (exclusive).newIndex- The new index of the first media item of the range. If the new index is larger than the size of the remaining playlist after removing the range, the range is moved to the end of the playlist.
-
removeMediaItem
public void removeMediaItem(int index)
Description copied from interface:PlayerRemoves the media item at the given index of the playlist.- Specified by:
removeMediaItemin interfacePlayer- Parameters:
index- The index at which to remove the media item.
-
removeMediaItems
public void removeMediaItems(int fromIndex, int toIndex)Description copied from interface:PlayerRemoves a range of media items from the playlist.- Specified by:
removeMediaItemsin interfacePlayer- Parameters:
fromIndex- The index at which to start removing media items.toIndex- The index of the first item to be kept (exclusive). If the index is larger than the size of the playlist, media items to the end of the playlist are removed.
-
clearMediaItems
public void clearMediaItems()
Description copied from interface:PlayerClears the playlist.- Specified by:
clearMediaItemsin interfacePlayer
-
isCommandAvailable
public boolean isCommandAvailable(@Command @com.google.android.exoplayer2.Player.Command int command)
Description copied from interface:PlayerReturns whether the providedPlayer.Commandis available.This method does not execute the command.
Executing a command that is not available (for example, calling
Player.seekToNextMediaItem()ifPlayer.COMMAND_SEEK_TO_NEXT_MEDIA_ITEMis unavailable) will neither throw an exception nor generate aPlayer.getPlayerError()player error}.Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEMandPlayer.COMMAND_SEEK_TO_NEXT_MEDIA_ITEMare unavailable if there is no suchMediaItem.- Specified by:
isCommandAvailablein interfacePlayer- Parameters:
command- APlayer.Command.- Returns:
- Whether the
Player.Commandis available. - See Also:
Player.Listener.onAvailableCommandsChanged(Commands)
-
canAdvertiseSession
public boolean canAdvertiseSession()
Description copied from interface:PlayerReturns whether the player can be used to advertise a media session.- Specified by:
canAdvertiseSessionin interfacePlayer
-
getAvailableCommands
public Player.Commands getAvailableCommands()
Description copied from interface:PlayerReturns the player's currently availablePlayer.Commands.The returned
Player.Commandsare not updated when available commands change. UsePlayer.Listener.onAvailableCommandsChanged(Commands)to get an update when the available commands change.Executing a command that is not available (for example, calling
Player.seekToNextMediaItem()ifPlayer.COMMAND_SEEK_TO_NEXT_MEDIA_ITEMis unavailable) will neither throw an exception nor generate aPlayer.getPlayerError()player error}.Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEMandPlayer.COMMAND_SEEK_TO_NEXT_MEDIA_ITEMare unavailable if there is no suchMediaItem.- Specified by:
getAvailableCommandsin interfacePlayer- Returns:
- The currently available
Player.Commands. - See Also:
Player.Listener.onAvailableCommandsChanged(com.google.android.exoplayer2.Player.Commands)
-
prepare
public void prepare()
Description copied from interface:PlayerPrepares the player.This will move the player out of
idle stateand the player will start loading media and acquire resources needed for playback.
-
getPlaybackState
public int getPlaybackState()
Description copied from interface:PlayerReturns the currentplayback stateof the player.- Specified by:
getPlaybackStatein interfacePlayer- Returns:
- The current
playback state. - See Also:
Player.Listener.onPlaybackStateChanged(int)
-
getPlaybackSuppressionReason
public int getPlaybackSuppressionReason()
Description copied from interface:PlayerReturns the reason why playback is suppressed even thoughPlayer.getPlayWhenReady()istrue, orPlayer.PLAYBACK_SUPPRESSION_REASON_NONEif playback is not suppressed.- Specified by:
getPlaybackSuppressionReasonin interfacePlayer- Returns:
- The current
playback suppression reason. - See Also:
Player.Listener.onPlaybackSuppressionReasonChanged(int)
-
isPlaying
public boolean isPlaying()
Description copied from interface:PlayerReturns whether the player is playing, i.e.Player.getCurrentPosition()is advancing.If
false, then at least one of the following is true:- The
playback stateis notready. - There is no
intention to play. - Playback is
suppressed for other reasons.
- Specified by:
isPlayingin interfacePlayer- Returns:
- Whether the player is playing.
- See Also:
Player.Listener.onIsPlayingChanged(boolean)
- The
-
getPlayerError
@Nullable public PlaybackException getPlayerError()
Description copied from interface:PlayerReturns 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
nullifPlayer.getPlaybackState()is notPlayer.STATE_IDLE.- Specified by:
getPlayerErrorin interfacePlayer- Returns:
- The error, or
null. - See Also:
Player.Listener.onPlayerError(PlaybackException)
-
play
public void play()
Description copied from interface:PlayerResumes playback as soon asPlayer.getPlaybackState()==Player.STATE_READY. Equivalent tosetPlayWhenReady(true).
-
pause
public void pause()
Description copied from interface:PlayerPauses playback. Equivalent tosetPlayWhenReady(false).
-
setPlayWhenReady
public void setPlayWhenReady(boolean playWhenReady)
Description copied from interface:PlayerSets whether playback should proceed whenPlayer.getPlaybackState()==Player.STATE_READY.If the player is already in the ready state then this method pauses and resumes playback.
- Specified by:
setPlayWhenReadyin interfacePlayer- Parameters:
playWhenReady- Whether playback should proceed when ready.
-
getPlayWhenReady
public boolean getPlayWhenReady()
Description copied from interface:PlayerWhether playback will proceed whenPlayer.getPlaybackState()==Player.STATE_READY.- Specified by:
getPlayWhenReadyin interfacePlayer- Returns:
- Whether playback will proceed when ready.
- See Also:
Player.Listener.onPlayWhenReadyChanged(boolean, int)
-
setRepeatMode
public void setRepeatMode(@RepeatMode @com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
Description copied from interface:PlayerSets thePlayer.RepeatModeto be used for playback.- Specified by:
setRepeatModein interfacePlayer- Parameters:
repeatMode- The repeat mode.
-
getRepeatMode
public int getRepeatMode()
Description copied from interface:PlayerReturns the currentPlayer.RepeatModeused for playback.- Specified by:
getRepeatModein interfacePlayer- Returns:
- The current repeat mode.
- See Also:
Player.Listener.onRepeatModeChanged(int)
-
setShuffleModeEnabled
public void setShuffleModeEnabled(boolean shuffleModeEnabled)
Description copied from interface:PlayerSets whether shuffling of media items is enabled.- Specified by:
setShuffleModeEnabledin interfacePlayer- Parameters:
shuffleModeEnabled- Whether shuffling is enabled.
-
getShuffleModeEnabled
public boolean getShuffleModeEnabled()
Description copied from interface:PlayerReturns whether shuffling of media items is enabled.- Specified by:
getShuffleModeEnabledin interfacePlayer- See Also:
Player.Listener.onShuffleModeEnabledChanged(boolean)
-
isLoading
public boolean isLoading()
Description copied from interface:PlayerWhether the player is currently loading the source.- Specified by:
isLoadingin interfacePlayer- Returns:
- Whether the player is currently loading the source.
- See Also:
Player.Listener.onIsLoadingChanged(boolean)
-
seekToDefaultPosition
public void seekToDefaultPosition()
Description copied from interface:PlayerSeeks 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.- Specified by:
seekToDefaultPositionin interfacePlayer
-
seekToDefaultPosition
public void seekToDefaultPosition(int mediaItemIndex)
Description copied from interface:PlayerSeeks 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.- Specified by:
seekToDefaultPositionin interfacePlayer- Parameters:
mediaItemIndex- The index of theMediaItemwhose associated default position should be seeked to.
-
seekTo
public void seekTo(long positionMs)
Description copied from interface:PlayerSeeks to a position specified in milliseconds in the currentMediaItem.- Specified by:
seekToin interfacePlayer- Parameters:
positionMs- The seek position in the currentMediaItem, orC.TIME_UNSETto seek to the media item's default position.
-
seekTo
public void seekTo(int mediaItemIndex, long positionMs)Description copied from interface:PlayerSeeks to a position specified in milliseconds in the specifiedMediaItem.- Specified by:
seekToin interfacePlayer- Parameters:
mediaItemIndex- The index of theMediaItem.positionMs- The seek position in the specifiedMediaItem, orC.TIME_UNSETto seek to the media item's default position.
-
getSeekBackIncrement
public long getSeekBackIncrement()
Description copied from interface:PlayerReturns thePlayer.seekBack()increment.- Specified by:
getSeekBackIncrementin interfacePlayer- Returns:
- The seek back increment, in milliseconds.
- See Also:
Player.Listener.onSeekBackIncrementChanged(long)
-
seekBack
public void seekBack()
Description copied from interface:PlayerSeeks back in the currentMediaItembyPlayer.getSeekBackIncrement()milliseconds.
-
getSeekForwardIncrement
public long getSeekForwardIncrement()
Description copied from interface:PlayerReturns thePlayer.seekForward()increment.- Specified by:
getSeekForwardIncrementin interfacePlayer- Returns:
- The seek forward increment, in milliseconds.
- See Also:
Player.Listener.onSeekForwardIncrementChanged(long)
-
seekForward
public void seekForward()
Description copied from interface:PlayerSeeks forward in the currentMediaItembyPlayer.getSeekForwardIncrement()milliseconds.- Specified by:
seekForwardin interfacePlayer
-
hasPrevious
@Deprecated public boolean hasPrevious()
Deprecated.- Specified by:
hasPreviousin interfacePlayer
-
hasPreviousWindow
@Deprecated public boolean hasPreviousWindow()
Deprecated.- Specified by:
hasPreviousWindowin interfacePlayer
-
hasPreviousMediaItem
public boolean hasPreviousMediaItem()
Description copied from interface:PlayerReturns 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
Player.REPEAT_MODE_ONE, this method behaves the same as when the current repeat mode isPlayer.REPEAT_MODE_OFF. SeePlayer.REPEAT_MODE_ONEfor more details.- Specified by:
hasPreviousMediaItemin interfacePlayer
-
previous
@Deprecated public void previous()
Deprecated.
-
seekToPreviousWindow
@Deprecated public void seekToPreviousWindow()
Deprecated.- Specified by:
seekToPreviousWindowin interfacePlayer
-
seekToPreviousMediaItem
public void seekToPreviousMediaItem()
Description copied from interface:PlayerSeeks to the default position of the previousMediaItem, which may depend on the current repeat mode and whether shuffle mode is enabled. Does nothing ifPlayer.hasPreviousMediaItem()isfalse.Note: When the repeat mode is
Player.REPEAT_MODE_ONE, this method behaves the same as when the current repeat mode isPlayer.REPEAT_MODE_OFF. SeePlayer.REPEAT_MODE_ONEfor more details.- Specified by:
seekToPreviousMediaItemin interfacePlayer
-
seekToPrevious
public void seekToPrevious()
Description copied from interface:PlayerSeeks 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
MediaItemisPlayer.isCurrentMediaItemLive()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 existsand thecurrent positionis less thanPlayer.getMaxSeekToPreviousPosition(), seeks to the default position of the previousMediaItem. - Otherwise, seeks to 0 in the current
MediaItem.
- Specified by:
seekToPreviousin interfacePlayer
-
getMaxSeekToPreviousPosition
public long getMaxSeekToPreviousPosition()
Description copied from interface:PlayerReturns the maximum position for whichPlayer.seekToPrevious()seeks to the previousMediaItem, in milliseconds.- Specified by:
getMaxSeekToPreviousPositionin interfacePlayer- Returns:
- The maximum seek to previous position, in milliseconds.
- See Also:
Player.EventListener.onMaxSeekToPreviousPositionChanged(long)
-
hasNext
@Deprecated public boolean hasNext()
Deprecated.
-
hasNextWindow
@Deprecated public boolean hasNextWindow()
Deprecated.- Specified by:
hasNextWindowin interfacePlayer
-
hasNextMediaItem
public boolean hasNextMediaItem()
Description copied from interface:PlayerReturns whether a nextMediaItemexists, which may depend on the current repeat mode and whether shuffle mode is enabled.Note: When the repeat mode is
Player.REPEAT_MODE_ONE, this method behaves the same as when the current repeat mode isPlayer.REPEAT_MODE_OFF. SeePlayer.REPEAT_MODE_ONEfor more details.- Specified by:
hasNextMediaItemin interfacePlayer
-
next
@Deprecated public void next()
Deprecated.
-
seekToNextWindow
@Deprecated public void seekToNextWindow()
Deprecated.- Specified by:
seekToNextWindowin interfacePlayer
-
seekToNextMediaItem
public void seekToNextMediaItem()
Description copied from interface:PlayerSeeks to the default position of the nextMediaItem, which may depend on the current repeat mode and whether shuffle mode is enabled. Does nothing ifPlayer.hasNextMediaItem()isfalse.Note: When the repeat mode is
Player.REPEAT_MODE_ONE, this method behaves the same as when the current repeat mode isPlayer.REPEAT_MODE_OFF. SeePlayer.REPEAT_MODE_ONEfor more details.- Specified by:
seekToNextMediaItemin interfacePlayer
-
seekToNext
public void seekToNext()
Description copied from interface:PlayerSeeks 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
MediaItemisliveand has not ended, seeks to the live edge of the currentMediaItem. - Otherwise, does nothing.
- Specified by:
seekToNextin interfacePlayer
-
setPlaybackParameters
public void setPlaybackParameters(PlaybackParameters playbackParameters)
Description copied from interface:PlayerAttempts to set the playback parameters. PassingPlaybackParameters.DEFAULTresets 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.- Specified by:
setPlaybackParametersin interfacePlayer- Parameters:
playbackParameters- The playback parameters.
-
setPlaybackSpeed
public void setPlaybackSpeed(float speed)
Description copied from interface:PlayerChanges the rate at which playback occurs. The pitch is not changed.This is equivalent to
setPlaybackParameters(getPlaybackParameters().withSpeed(speed)).- Specified by:
setPlaybackSpeedin interfacePlayer- 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
public PlaybackParameters getPlaybackParameters()
Description copied from interface:PlayerReturns the currently active playback parameters.- Specified by:
getPlaybackParametersin interfacePlayer- See Also:
Player.Listener.onPlaybackParametersChanged(PlaybackParameters)
-
stop
public void stop()
Description copied from interface:PlayerStops playback without resetting the playlist. UsePlayer.pause()rather than this method if the intention is to pause playback.Calling this method will cause the playback state to transition to
Player.STATE_IDLEand the player will release the loaded media and resources required for playback. The player instance can still be used by callingPlayer.prepare()again, andPlayer.release()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.
-
stop
@Deprecated public void stop(boolean reset)
Deprecated.
-
release
public void release()
Description copied from interface:PlayerReleases the player. This method must be called when the player is no longer required. The player must not be used after calling this method.
-
getCurrentTrackGroups
public TrackGroupArray getCurrentTrackGroups()
Description copied from interface:PlayerReturns the available track groups.- Specified by:
getCurrentTrackGroupsin interfacePlayer- See Also:
Player.EventListener.onTracksChanged(TrackGroupArray, TrackSelectionArray)
-
getCurrentTrackSelections
public TrackSelectionArray getCurrentTrackSelections()
Description copied from interface:PlayerReturns the current track selections.A concrete implementation may include null elements if it has a fixed number of renderer components, wishes to report a TrackSelection for each of them, and has one or more renderer components that is not assigned any selected tracks.
- Specified by:
getCurrentTrackSelectionsin interfacePlayer- See Also:
Player.EventListener.onTracksChanged(TrackGroupArray, TrackSelectionArray)
-
getCurrentTracksInfo
public TracksInfo getCurrentTracksInfo()
Description copied from interface:PlayerReturns the available tracks, as well as the tracks' support, type, and selection status.- Specified by:
getCurrentTracksInfoin interfacePlayer- See Also:
Player.EventListener.onTracksChanged(TrackGroupArray, TrackSelectionArray)
-
getTrackSelectionParameters
public TrackSelectionParameters getTrackSelectionParameters()
Description copied from interface:PlayerReturns the parameters constraining the track selection.- Specified by:
getTrackSelectionParametersin interfacePlayer- See Also:
}
-
setTrackSelectionParameters
public void setTrackSelectionParameters(TrackSelectionParameters parameters)
Description copied from interface:PlayerSets the parameters constraining the track selection.Unsupported parameters will be silently ignored.
Use
Player.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())- Specified by:
setTrackSelectionParametersin interfacePlayer
-
getMediaMetadata
public MediaMetadata getMediaMetadata()
Description copied from interface:PlayerReturns the current combinedMediaMetadata, orMediaMetadata.EMPTYif not supported.This
MediaMetadatais a combination of theMediaItem.mediaMetadataand the static and dynamic metadata from thetrack selections' formatsandPlayer.Listener.onMetadata(Metadata). If a field is populated in theMediaItem.mediaMetadata, it will be prioritised above the same field coming from static or dynamic metadata.- Specified by:
getMediaMetadatain interfacePlayer
-
getPlaylistMetadata
public MediaMetadata getPlaylistMetadata()
Description copied from interface:PlayerReturns the playlistMediaMetadata, as set byPlayer.setPlaylistMetadata(MediaMetadata), orMediaMetadata.EMPTYif not supported.- Specified by:
getPlaylistMetadatain interfacePlayer
-
setPlaylistMetadata
public void setPlaylistMetadata(MediaMetadata mediaMetadata)
Description copied from interface:PlayerSets the playlistMediaMetadata.- Specified by:
setPlaylistMetadatain interfacePlayer
-
getCurrentManifest
@Nullable public Object getCurrentManifest()
Description copied from interface:PlayerReturns the current manifest. The type depends on the type of media being played. May be null.- Specified by:
getCurrentManifestin interfacePlayer
-
getCurrentTimeline
public Timeline getCurrentTimeline()
Description copied from interface:PlayerReturns the currentTimeline. Never null, but may be empty.- Specified by:
getCurrentTimelinein interfacePlayer- See Also:
Player.Listener.onTimelineChanged(Timeline, int)
-
getCurrentPeriodIndex
public int getCurrentPeriodIndex()
Description copied from interface:PlayerReturns the index of the period currently being played.- Specified by:
getCurrentPeriodIndexin interfacePlayer
-
getCurrentWindowIndex
@Deprecated public int getCurrentWindowIndex()
Deprecated.- Specified by:
getCurrentWindowIndexin interfacePlayer
-
getCurrentMediaItemIndex
public int getCurrentMediaItemIndex()
Description copied from interface:PlayerReturns the index of the currentMediaItemin thetimeline, or the prospective index if thecurrent timelineis empty.- Specified by:
getCurrentMediaItemIndexin interfacePlayer
-
getNextWindowIndex
@Deprecated public int getNextWindowIndex()
Deprecated.- Specified by:
getNextWindowIndexin interfacePlayer
-
getNextMediaItemIndex
public int getNextMediaItemIndex()
Description copied from interface:PlayerReturns the index of theMediaItemthat will be played ifPlayer.seekToNextMediaItem()is called, which may depend on the current repeat mode and whether shuffle mode is enabled. ReturnsC.INDEX_UNSETifPlayer.hasNextMediaItem()isfalse.Note: When the repeat mode is
Player.REPEAT_MODE_ONE, this method behaves the same as when the current repeat mode isPlayer.REPEAT_MODE_OFF. SeePlayer.REPEAT_MODE_ONEfor more details.- Specified by:
getNextMediaItemIndexin interfacePlayer
-
getPreviousWindowIndex
@Deprecated public int getPreviousWindowIndex()
Deprecated.- Specified by:
getPreviousWindowIndexin interfacePlayer
-
getPreviousMediaItemIndex
public int getPreviousMediaItemIndex()
Description copied from interface:PlayerReturns the index of theMediaItemthat will be played ifPlayer.seekToPreviousMediaItem()is called, which may depend on the current repeat mode and whether shuffle mode is enabled. ReturnsC.INDEX_UNSETifPlayer.hasPreviousMediaItem()isfalse.Note: When the repeat mode is
Player.REPEAT_MODE_ONE, this method behaves the same as when the current repeat mode isPlayer.REPEAT_MODE_OFF. SeePlayer.REPEAT_MODE_ONEfor more details.- Specified by:
getPreviousMediaItemIndexin interfacePlayer
-
getCurrentMediaItem
@Nullable public MediaItem getCurrentMediaItem()
Description copied from interface:PlayerReturns the currently playingMediaItem. May be null if the timeline is empty.- Specified by:
getCurrentMediaItemin interfacePlayer- See Also:
Player.Listener.onMediaItemTransition(MediaItem, int)
-
getMediaItemCount
public int getMediaItemCount()
Description copied from interface:PlayerReturns the number ofmedia itemsin the playlist.- Specified by:
getMediaItemCountin interfacePlayer
-
getMediaItemAt
public MediaItem getMediaItemAt(int index)
Description copied from interface:PlayerReturns theMediaItemat the given index.- Specified by:
getMediaItemAtin interfacePlayer
-
getDuration
public long getDuration()
Description copied from interface:PlayerReturns the duration of the current content or ad in milliseconds, orC.TIME_UNSETif the duration is not known.- Specified by:
getDurationin interfacePlayer
-
getCurrentPosition
public long getCurrentPosition()
Description copied from interface:PlayerReturns the playback position in the current content or ad, in milliseconds, or the prospective position in milliseconds if thecurrent timelineis empty.- Specified by:
getCurrentPositionin interfacePlayer
-
getBufferedPosition
public long getBufferedPosition()
Description copied from interface:PlayerReturns an estimate of the position in the current content or ad up to which data is buffered, in milliseconds.- Specified by:
getBufferedPositionin interfacePlayer
-
getBufferedPercentage
public int getBufferedPercentage()
Description copied from interface:PlayerReturns an estimate of the percentage in the current content or ad up to which data is buffered, or 0 if no estimate is available.- Specified by:
getBufferedPercentagein interfacePlayer
-
getTotalBufferedDuration
public long getTotalBufferedDuration()
Description copied from interface:PlayerReturns an estimate of the total buffered duration from the current position, in milliseconds. This includes pre-buffered data for subsequent ads andmedia items.- Specified by:
getTotalBufferedDurationin interfacePlayer
-
isCurrentWindowDynamic
@Deprecated public boolean isCurrentWindowDynamic()
Deprecated.- Specified by:
isCurrentWindowDynamicin interfacePlayer
-
isCurrentMediaItemDynamic
public boolean isCurrentMediaItemDynamic()
Description copied from interface:PlayerReturns whether the currentMediaItemis dynamic (may change when theTimelineis updated), orfalseif theTimelineis empty.- Specified by:
isCurrentMediaItemDynamicin interfacePlayer- See Also:
Timeline.Window.isDynamic
-
isCurrentWindowLive
@Deprecated public boolean isCurrentWindowLive()
Deprecated.- Specified by:
isCurrentWindowLivein interfacePlayer
-
isCurrentMediaItemLive
public boolean isCurrentMediaItemLive()
Description copied from interface:Player- Specified by:
isCurrentMediaItemLivein interfacePlayer- See Also:
Timeline.Window.isLive()
-
getCurrentLiveOffset
public long getCurrentLiveOffset()
Description copied from interface:PlayerReturns the offset of the current playback position from the live edge in milliseconds, orC.TIME_UNSETif the currentMediaItemPlayer.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.
- Specified by:
getCurrentLiveOffsetin interfacePlayer
-
isCurrentWindowSeekable
@Deprecated public boolean isCurrentWindowSeekable()
Deprecated.- Specified by:
isCurrentWindowSeekablein interfacePlayer
-
isCurrentMediaItemSeekable
public boolean isCurrentMediaItemSeekable()
Description copied from interface:Player- Specified by:
isCurrentMediaItemSeekablein interfacePlayer- See Also:
Timeline.Window.isSeekable
-
isPlayingAd
public boolean isPlayingAd()
Description copied from interface:PlayerReturns whether the player is currently playing an ad.- Specified by:
isPlayingAdin interfacePlayer
-
getCurrentAdGroupIndex
public int getCurrentAdGroupIndex()
Description copied from interface:PlayerIfPlayer.isPlayingAd()returns true, returns the index of the ad group in the period currently being played. ReturnsC.INDEX_UNSETotherwise.- Specified by:
getCurrentAdGroupIndexin interfacePlayer
-
getCurrentAdIndexInAdGroup
public int getCurrentAdIndexInAdGroup()
Description copied from interface:PlayerIfPlayer.isPlayingAd()returns true, returns the index of the ad in its ad group. ReturnsC.INDEX_UNSETotherwise.- Specified by:
getCurrentAdIndexInAdGroupin interfacePlayer
-
getContentDuration
public long getContentDuration()
Description copied from interface:PlayerIfPlayer.isPlayingAd()returnstrue, returns the duration of the current content in milliseconds, orC.TIME_UNSETif the duration is not known. If there is no ad playing, the returned duration is the same as that returned byPlayer.getDuration().- Specified by:
getContentDurationin interfacePlayer
-
getContentPosition
public long getContentPosition()
Description copied from interface:PlayerIfPlayer.isPlayingAd()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 byPlayer.getCurrentPosition().- Specified by:
getContentPositionin interfacePlayer
-
getContentBufferedPosition
public long getContentBufferedPosition()
Description copied from interface:PlayerIfPlayer.isPlayingAd()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 byPlayer.getBufferedPosition().- Specified by:
getContentBufferedPositionin interfacePlayer
-
getAudioAttributes
public AudioAttributes getAudioAttributes()
Description copied from interface:PlayerReturns the attributes for audio playback.- Specified by:
getAudioAttributesin interfacePlayer
-
setVolume
public void setVolume(float volume)
Description copied from interface:PlayerSets the audio volume, valid values are between 0 (silence) and 1 (unity gain, signal unchanged), inclusive.
-
getVolume
public float getVolume()
Description copied from interface:PlayerReturns the audio volume, with 0 being silence and 1 being unity gain (signal unchanged).
-
getVideoSize
public VideoSize getVideoSize()
Description copied from interface:PlayerGets the size of the video.The video's width and height are
0if there is no video or its size has not been determined yet.- Specified by:
getVideoSizein interfacePlayer- See Also:
Player.Listener.onVideoSizeChanged(VideoSize)
-
clearVideoSurface
public void clearVideoSurface()
Description copied from interface:Player- Specified by:
clearVideoSurfacein interfacePlayer
-
clearVideoSurface
public void clearVideoSurface(@Nullable Surface surface)Description copied from interface:PlayerClears theSurfaceonto which video is being rendered if it matches the one passed. Else does nothing.- Specified by:
clearVideoSurfacein interfacePlayer- Parameters:
surface- The surface to clear.
-
setVideoSurface
public void setVideoSurface(@Nullable Surface surface)Description copied from interface:PlayerSets theSurfaceonto 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,TextureVieworSurfaceHolderthen it's recommended to usePlayer.setVideoSurfaceView(SurfaceView),Player.setVideoTextureView(TextureView)orPlayer.setVideoSurfaceHolder(SurfaceHolder)rather than this method, since passing the holder allows the player to track the lifecycle of the surface automatically.- Specified by:
setVideoSurfacein interfacePlayer- Parameters:
surface- TheSurface.
-
setVideoSurfaceHolder
public void setVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder)Description copied from interface:PlayerSets theSurfaceHolderthat holds theSurfaceonto which video will be rendered. The player will track the lifecycle of the surface automatically.The thread that calls the
SurfaceHolder.Callbackmethods must be the thread associated withPlayer.getApplicationLooper().- Specified by:
setVideoSurfaceHolderin interfacePlayer- Parameters:
surfaceHolder- The surface holder.
-
clearVideoSurfaceHolder
public void clearVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder)Description copied from interface:PlayerClears theSurfaceHolderthat holds theSurfaceonto which video is being rendered if it matches the one passed. Else does nothing.- Specified by:
clearVideoSurfaceHolderin interfacePlayer- Parameters:
surfaceHolder- The surface holder to clear.
-
setVideoSurfaceView
public void setVideoSurfaceView(@Nullable SurfaceView surfaceView)Description copied from interface:PlayerSets theSurfaceViewonto which video will be rendered. The player will track the lifecycle of the surface automatically.The thread that calls the
SurfaceHolder.Callbackmethods must be the thread associated withPlayer.getApplicationLooper().- Specified by:
setVideoSurfaceViewin interfacePlayer- Parameters:
surfaceView- The surface view.
-
clearVideoSurfaceView
public void clearVideoSurfaceView(@Nullable SurfaceView surfaceView)Description copied from interface:PlayerClears theSurfaceViewonto which video is being rendered if it matches the one passed. Else does nothing.- Specified by:
clearVideoSurfaceViewin interfacePlayer- Parameters:
surfaceView- The texture view to clear.
-
setVideoTextureView
public void setVideoTextureView(@Nullable TextureView textureView)Description copied from interface:PlayerSets theTextureViewonto which video will be rendered. The player will track the lifecycle of the surface automatically.The thread that calls the
TextureView.SurfaceTextureListenermethods must be the thread associated withPlayer.getApplicationLooper().- Specified by:
setVideoTextureViewin interfacePlayer- Parameters:
textureView- The texture view.
-
clearVideoTextureView
public void clearVideoTextureView(@Nullable TextureView textureView)Description copied from interface:PlayerClears theTextureViewonto which video is being rendered if it matches the one passed. Else does nothing.- Specified by:
clearVideoTextureViewin interfacePlayer- Parameters:
textureView- The texture view to clear.
-
getCurrentCues
public List<Cue> getCurrentCues()
Description copied from interface:PlayerReturns the currentCues. This list may be empty.- Specified by:
getCurrentCuesin interfacePlayer
-
getDeviceInfo
public DeviceInfo getDeviceInfo()
Description copied from interface:PlayerGets the device information.- Specified by:
getDeviceInfoin interfacePlayer
-
getDeviceVolume
public int getDeviceVolume()
Description copied from interface:PlayerGets 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.usagewhich can be converted to stream type withUtil.getStreamTypeForAudioUsage(int).For devices with
remote playback, the volume of the remote device is returned.- Specified by:
getDeviceVolumein interfacePlayer
-
isDeviceMuted
public boolean isDeviceMuted()
Description copied from interface:PlayerGets whether the device is muted or not.- Specified by:
isDeviceMutedin interfacePlayer
-
setDeviceVolume
public void setDeviceVolume(int volume)
Description copied from interface:PlayerSets the volume of the device.- Specified by:
setDeviceVolumein interfacePlayer- Parameters:
volume- The volume to set.
-
increaseDeviceVolume
public void increaseDeviceVolume()
Description copied from interface:PlayerIncreases the volume of the device.- Specified by:
increaseDeviceVolumein interfacePlayer
-
decreaseDeviceVolume
public void decreaseDeviceVolume()
Description copied from interface:PlayerDecreases the volume of the device.- Specified by:
decreaseDeviceVolumein interfacePlayer
-
setDeviceMuted
public void setDeviceMuted(boolean muted)
Description copied from interface:PlayerSets the mute state of the device.- Specified by:
setDeviceMutedin interfacePlayer
-
-