Class CastPlayer
- java.lang.Object
-
- com.google.android.exoplayer2.BasePlayer
-
- com.google.android.exoplayer2.ext.cast.CastPlayer
-
- All Implemented Interfaces:
Player
public final class CastPlayer extends BasePlayer
Playerimplementation that communicates with a Cast receiver app.The behavior of this class depends on the underlying Cast session, which is obtained from the injected
CastContext. To keep track of the session,isCastSessionAvailable()can be queried andSessionAvailabilityListenercan be implemented and attached to the player.If no session is available, the player state will remain unchanged and calls to methods that alter it will be ignored. Querying the player state is possible even when no session is available, in which case, the last observed receiver app state is reported.
Methods should be called on the application's main thread.
-
-
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 Modifier and Type Field Description static floatMAX_SPEED_SUPPORTEDstatic floatMIN_SPEED_SUPPORTED-
Fields inherited from class com.google.android.exoplayer2.BasePlayer
window
-
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 CastPlayer(com.google.android.gms.cast.framework.CastContext castContext)Creates a new cast player.CastPlayer(com.google.android.gms.cast.framework.CastContext castContext, MediaItemConverter mediaItemConverter)Creates a new cast player.CastPlayer(com.google.android.gms.cast.framework.CastContext castContext, MediaItemConverter mediaItemConverter, long seekBackIncrementMs, long seekForwardIncrementMs)Creates a new cast player.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddListener(Player.EventListener listener)Deprecated.UseaddListener(Listener)andremoveListener(Listener)instead.voidaddListener(Player.Listener listener)Registers a listener to receive all events from the player.voidaddMediaItems(int index, List<MediaItem> mediaItems)Adds a list of media items at the given index of the playlist.voidclearVideoSurface()This method is not supported and does nothing.voidclearVideoSurface(Surface surface)This method is not supported and does nothing.voidclearVideoSurfaceHolder(SurfaceHolder surfaceHolder)This method is not supported and does nothing.voidclearVideoSurfaceView(SurfaceView surfaceView)This method is not supported and does nothing.voidclearVideoTextureView(TextureView textureView)This method is not supported and does nothing.voiddecreaseDeviceVolume()This method is not supported and does nothing.LoopergetApplicationLooper()Returns theLooperassociated with the application thread that's used to access the player and on which player events are received.AudioAttributesgetAudioAttributes()This method is not supported and returnsAudioAttributes.DEFAULT.Player.CommandsgetAvailableCommands()Returns the player's currently availablePlayer.Commands.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.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.ImmutableList<Cue>getCurrentCues()This method is not supported and returns an empty list.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.DeviceInfogetDeviceInfo()This method is not supported and always returnsDeviceInfo.UNKNOWN.intgetDeviceVolume()This method is not supported and always returns0.longgetDuration()Returns the duration of the current content or ad in milliseconds, orC.TIME_UNSETif the duration is not known.com.google.android.gms.cast.MediaQueueItemgetItem(int periodId)Returns the item that corresponds to the period with the given id, or null if no media queue or period with idperiodIdexist.longgetMaxSeekToPreviousPosition()Returns the maximum position for whichPlayer.seekToPrevious()seeks to the previousMediaItem, in milliseconds.MediaMetadatagetMediaMetadata()Returns the current combinedMediaMetadata, orMediaMetadata.EMPTYif not supported.PlaybackParametersgetPlaybackParameters()Returns the currently active playback parameters.@com.google.android.exoplayer2.Player.State intgetPlaybackState()Returns the currentplayback stateof the player.@com.google.android.exoplayer2.Player.PlaybackSuppressionReason 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.@com.google.android.exoplayer2.Player.RepeatMode 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()This method is not supported and returnsVideoSize.UNKNOWN.floatgetVolume()This method is not supported and returns 1.voidincreaseDeviceVolume()This method is not supported and does nothing.booleanisCastSessionAvailable()Returns whether a cast session is available.booleanisDeviceMuted()This method is not supported and always returnsfalse.booleanisLoading()Whether the player is currently loading the source.booleanisPlayingAd()Returns whether the player is currently playing an ad.voidmoveMediaItems(int fromIndex, int toIndex, int newIndex)Moves the media item range to the new index.voidprepare()Prepares the player.voidrelease()Releases the player.voidremoveListener(Player.EventListener listener)Deprecated.UseaddListener(Listener)andremoveListener(Listener)instead.voidremoveListener(Player.Listener listener)Unregister a listener registered throughPlayer.addListener(Listener).voidremoveMediaItems(int fromIndex, int toIndex)Removes a range of media items from the playlist.voidseekTo(int mediaItemIndex, long positionMs)Seeks to a position specified in milliseconds in the specifiedMediaItem.voidsetDeviceMuted(boolean muted)This method is not supported and does nothing.voidsetDeviceVolume(int volume)This method is not supported and does nothing.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.voidsetPlaylistMetadata(MediaMetadata mediaMetadata)This method is not supported and does nothing.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.voidsetSessionAvailabilityListener(SessionAvailabilityListener listener)Sets a listener for updates on the cast session availability.voidsetShuffleModeEnabled(boolean shuffleModeEnabled)Sets whether shuffling of media items is enabled.voidsetTrackSelectionParameters(TrackSelectionParameters parameters)Sets the parameters constraining the track selection.voidsetVideoSurface(Surface surface)This method is not supported and does nothing.voidsetVideoSurfaceHolder(SurfaceHolder surfaceHolder)This method is not supported and does nothing.voidsetVideoSurfaceView(SurfaceView surfaceView)This method is not supported and does nothing.voidsetVideoTextureView(TextureView textureView)This method is not supported and does nothing.voidsetVolume(float volume)This method is not supported and does nothing.voidstop()Stops playback without resetting the playlist.voidstop(boolean reset)Deprecated.-
Methods inherited from class com.google.android.exoplayer2.BasePlayer
addMediaItem, addMediaItem, addMediaItems, canAdvertiseSession, clearMediaItems, getAvailableCommands, getBufferedPercentage, getContentDuration, getCurrentLiveOffset, getCurrentManifest, getCurrentMediaItem, getCurrentWindowIndex, getMediaItemAt, getMediaItemCount, getNextMediaItemIndex, getNextWindowIndex, getPreviousMediaItemIndex, getPreviousWindowIndex, hasNext, hasNextMediaItem, hasNextWindow, hasPrevious, hasPreviousMediaItem, hasPreviousWindow, isCommandAvailable, isCurrentMediaItemDynamic, isCurrentMediaItemLive, isCurrentMediaItemSeekable, isCurrentWindowDynamic, isCurrentWindowLive, isCurrentWindowSeekable, isPlaying, moveMediaItem, next, pause, play, previous, removeMediaItem, seekBack, seekForward, seekTo, seekToDefaultPosition, seekToDefaultPosition, seekToNext, seekToNextMediaItem, seekToNextWindow, seekToPrevious, seekToPreviousMediaItem, seekToPreviousWindow, setMediaItem, setMediaItem, setMediaItem, setMediaItems, setPlaybackSpeed
-
-
-
-
Field Detail
-
MIN_SPEED_SUPPORTED
public static final float MIN_SPEED_SUPPORTED
- See Also:
- Constant Field Values
-
MAX_SPEED_SUPPORTED
public static final float MAX_SPEED_SUPPORTED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CastPlayer
public CastPlayer(com.google.android.gms.cast.framework.CastContext castContext)
Creates a new cast player.The returned player uses a
DefaultMediaItemConverterandmediaItemConverteris set to aDefaultMediaItemConverter,seekBackIncrementMsis set toC.DEFAULT_SEEK_BACK_INCREMENT_MSandseekForwardIncrementMsis set toC.DEFAULT_SEEK_FORWARD_INCREMENT_MS.- Parameters:
castContext- The context from which the cast session is obtained.
-
CastPlayer
public CastPlayer(com.google.android.gms.cast.framework.CastContext castContext, MediaItemConverter mediaItemConverter)Creates a new cast player.seekBackIncrementMsis set toC.DEFAULT_SEEK_BACK_INCREMENT_MSandseekForwardIncrementMsis set toC.DEFAULT_SEEK_FORWARD_INCREMENT_MS.- Parameters:
castContext- The context from which the cast session is obtained.mediaItemConverter- TheMediaItemConverterto use.
-
CastPlayer
public CastPlayer(com.google.android.gms.cast.framework.CastContext castContext, MediaItemConverter mediaItemConverter, @IntRange(from=1L) long seekBackIncrementMs, @IntRange(from=1L) long seekForwardIncrementMs)Creates a new cast player.- Parameters:
castContext- The context from which the cast session is obtained.mediaItemConverter- TheMediaItemConverterto use.seekBackIncrementMs- TheBasePlayer.seekBack()increment, in milliseconds.seekForwardIncrementMs- TheBasePlayer.seekForward()increment, in milliseconds.- Throws:
IllegalArgumentException- IfseekBackIncrementMsorseekForwardIncrementMsis non-positive.
-
-
Method Detail
-
getItem
@Nullable public com.google.android.gms.cast.MediaQueueItem getItem(int periodId)
Returns the item that corresponds to the period with the given id, or null if no media queue or period with idperiodIdexist.- Parameters:
periodId- The id of the period (getCurrentTimeline()) that corresponds to the item to get.- Returns:
- The item that corresponds to the period with the given id, or null if no media queue or
period with id
periodIdexist.
-
isCastSessionAvailable
public boolean isCastSessionAvailable()
Returns whether a cast session is available.
-
setSessionAvailabilityListener
public void setSessionAvailabilityListener(@Nullable SessionAvailabilityListener listener)Sets a listener for updates on the cast session availability.- Parameters:
listener- TheSessionAvailabilityListener, or null to clear the listener.
-
getApplicationLooper
public Looper getApplicationLooper()
Description copied from interface:PlayerReturns theLooperassociated with the application thread that's used to access the player and on which player events are received.
-
addListener
public void addListener(Player.Listener listener)
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().- Parameters:
listener- The listener to register.
-
addListener
@Deprecated public void addListener(Player.EventListener listener)
Deprecated.UseaddListener(Listener)andremoveListener(Listener)instead.Registers a listener to receive events from the player.The listener's methods will be called on the thread associated with
getApplicationLooper().- 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.- Parameters:
listener- The listener to unregister.
-
removeListener
@Deprecated public void removeListener(Player.EventListener listener)
Deprecated.UseaddListener(Listener)andremoveListener(Listener)instead.Unregister a listener registered throughaddListener(EventListener). The listener will no longer receive events from the player.- Parameters:
listener- The listener to unregister.
-
setMediaItems
public void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition)
Description copied from interface:PlayerClears the playlist and adds the specifiedMediaItems.- 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.- 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.
-
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.- 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.
-
moveMediaItems
public void moveMediaItems(int fromIndex, int toIndex, int newIndex)Description copied from interface:PlayerMoves the media item range to the new index.- 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.
-
removeMediaItems
public void removeMediaItems(int fromIndex, int toIndex)Description copied from interface:PlayerRemoves a range of media items from the playlist.- 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.
-
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.- 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
@State public @com.google.android.exoplayer2.Player.State int getPlaybackState()
Description copied from interface:PlayerReturns the currentplayback stateof the player.- Returns:
- The current
playback state. - See Also:
Player.Listener.onPlaybackStateChanged(int)
-
getPlaybackSuppressionReason
@PlaybackSuppressionReason public @com.google.android.exoplayer2.Player.PlaybackSuppressionReason 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.- Returns:
- The current
playback suppression reason. - See Also:
Player.Listener.onPlaybackSuppressionReasonChanged(int)
-
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.- Returns:
- The error, or
null. - See Also:
Player.Listener.onPlayerError(PlaybackException)
-
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.
- 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.- Returns:
- Whether playback will proceed when ready.
- See Also:
Player.Listener.onPlayWhenReadyChanged(boolean, int)
-
seekTo
public void seekTo(int mediaItemIndex, long positionMs)Description copied from interface:PlayerSeeks to a position specified in milliseconds in the specifiedMediaItem.- 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.- Returns:
- The seek back increment, in milliseconds.
- See Also:
Player.Listener.onSeekBackIncrementChanged(long)
-
getSeekForwardIncrement
public long getSeekForwardIncrement()
Description copied from interface:PlayerReturns thePlayer.seekForward()increment.- Returns:
- The seek forward increment, in milliseconds.
- See Also:
Player.Listener.onSeekForwardIncrementChanged(long)
-
getMaxSeekToPreviousPosition
public long getMaxSeekToPreviousPosition()
Description copied from interface:PlayerReturns the maximum position for whichPlayer.seekToPrevious()seeks to the previousMediaItem, in milliseconds.- Returns:
- The maximum seek to previous position, in milliseconds.
- See Also:
Player.EventListener.onMaxSeekToPreviousPositionChanged(long)
-
getPlaybackParameters
public PlaybackParameters getPlaybackParameters()
Description copied from interface:PlayerReturns the currently active playback parameters.
-
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.
-
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.- Parameters:
playbackParameters- The playback parameters.
-
setRepeatMode
public void setRepeatMode(@RepeatMode @com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
Description copied from interface:PlayerSets thePlayer.RepeatModeto be used for playback.- Parameters:
repeatMode- The repeat mode.
-
getRepeatMode
@RepeatMode public @com.google.android.exoplayer2.Player.RepeatMode int getRepeatMode()
Description copied from interface:PlayerReturns the currentPlayer.RepeatModeused for playback.- 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.- Parameters:
shuffleModeEnabled- Whether shuffling is enabled.
-
getShuffleModeEnabled
public boolean getShuffleModeEnabled()
Description copied from interface:PlayerReturns whether shuffling of media items is enabled.
-
getCurrentTrackGroups
public TrackGroupArray getCurrentTrackGroups()
Description copied from interface:PlayerReturns the available track groups.
-
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.
-
getCurrentTracksInfo
public TracksInfo getCurrentTracksInfo()
Description copied from interface:PlayerReturns the available tracks, as well as the tracks' support, type, and selection status.
-
getTrackSelectionParameters
public TrackSelectionParameters getTrackSelectionParameters()
Description copied from interface:PlayerReturns the parameters constraining the track selection.- 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())
-
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.
-
getPlaylistMetadata
public MediaMetadata getPlaylistMetadata()
Description copied from interface:PlayerReturns the playlistMediaMetadata, as set byPlayer.setPlaylistMetadata(MediaMetadata), orMediaMetadata.EMPTYif not supported.
-
setPlaylistMetadata
public void setPlaylistMetadata(MediaMetadata mediaMetadata)
This method is not supported and does nothing.
-
getCurrentTimeline
public Timeline getCurrentTimeline()
Description copied from interface:PlayerReturns the currentTimeline. Never null, but may be empty.
-
getCurrentPeriodIndex
public int getCurrentPeriodIndex()
Description copied from interface:PlayerReturns the index of the period currently being played.
-
getCurrentMediaItemIndex
public int getCurrentMediaItemIndex()
Description copied from interface:PlayerReturns the index of the currentMediaItemin thetimeline, or the prospective index if thecurrent timelineis empty.
-
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.
-
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.
-
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.
-
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.
-
isPlayingAd
public boolean isPlayingAd()
Description copied from interface:PlayerReturns whether the player is currently playing an ad.
-
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.
-
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.
-
isLoading
public boolean isLoading()
Description copied from interface:PlayerWhether the player is currently loading the source.- Returns:
- Whether the player is currently loading the source.
- See Also:
Player.Listener.onIsLoadingChanged(boolean)
-
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().
-
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().
-
getAudioAttributes
public AudioAttributes getAudioAttributes()
This method is not supported and returnsAudioAttributes.DEFAULT.
-
setVolume
public void setVolume(float volume)
This method is not supported and does nothing.- Parameters:
volume- Linear output gain to apply to all audio channels.
-
getVolume
public float getVolume()
This method is not supported and returns 1.- Returns:
- The linear gain applied to all audio channels.
-
clearVideoSurface
public void clearVideoSurface()
This method is not supported and does nothing.
-
clearVideoSurface
public void clearVideoSurface(@Nullable Surface surface)This method is not supported and does nothing.- Parameters:
surface- The surface to clear.
-
setVideoSurface
public void setVideoSurface(@Nullable Surface surface)This method is not supported and does nothing.- Parameters:
surface- TheSurface.
-
setVideoSurfaceHolder
public void setVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder)This method is not supported and does nothing.- Parameters:
surfaceHolder- The surface holder.
-
clearVideoSurfaceHolder
public void clearVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder)This method is not supported and does nothing.- Parameters:
surfaceHolder- The surface holder to clear.
-
setVideoSurfaceView
public void setVideoSurfaceView(@Nullable SurfaceView surfaceView)This method is not supported and does nothing.- Parameters:
surfaceView- The surface view.
-
clearVideoSurfaceView
public void clearVideoSurfaceView(@Nullable SurfaceView surfaceView)This method is not supported and does nothing.- Parameters:
surfaceView- The texture view to clear.
-
setVideoTextureView
public void setVideoTextureView(@Nullable TextureView textureView)This method is not supported and does nothing.- Parameters:
textureView- The texture view.
-
clearVideoTextureView
public void clearVideoTextureView(@Nullable TextureView textureView)This method is not supported and does nothing.- Parameters:
textureView- The texture view to clear.
-
getVideoSize
public VideoSize getVideoSize()
This method is not supported and returnsVideoSize.UNKNOWN.
-
getCurrentCues
public ImmutableList<Cue> getCurrentCues()
This method is not supported and returns an empty list.
-
getDeviceInfo
public DeviceInfo getDeviceInfo()
This method is not supported and always returnsDeviceInfo.UNKNOWN.
-
getDeviceVolume
public int getDeviceVolume()
This method is not supported and always returns0.
-
isDeviceMuted
public boolean isDeviceMuted()
This method is not supported and always returnsfalse.
-
setDeviceVolume
public void setDeviceVolume(int volume)
This method is not supported and does nothing.- Parameters:
volume- The volume to set.
-
increaseDeviceVolume
public void increaseDeviceVolume()
This method is not supported and does nothing.
-
decreaseDeviceVolume
public void decreaseDeviceVolume()
This method is not supported and does nothing.
-
setDeviceMuted
public void setDeviceMuted(boolean muted)
This method is not supported and does nothing.
-
-