ForwardingPlayer
@UnstableApi
public class ForwardingPlayer implements Player
CastPlayer |
|
A Player that forwards method calls to another Player. Applications can use this class to suppress or modify specific operations, by overriding the respective methods.
Subclasses must ensure they maintain consistency with the Player interface, including interactions with Player.Listener, which can be quite fiddly. For example, if removing an available Player.Command and disabling the corresponding method, subclasses need to:
- Override
isCommandAvailableandgetAvailableCommands - Override and no-op the method itself
- Override
addListenerand wrap the providedPlayer.Listenerwith an implementation that drops calls toonAvailableCommandsChangedandonEventsif they were only triggered by a change in command availability that is 'invisible' after the command removal.
Many customization use-cases are instead better served by ForwardingSimpleBasePlayer, which allows subclasses to more concisely modify the behavior of an operation, or disallow a Player.Command. In many cases ForwardingSimpleBasePlayer should be used in preference to ForwardingPlayer.
Summary
Public constructors |
|---|
ForwardingPlayer(Player player)Creates a new instance that forwards all operations to |
Public methods |
|
|---|---|
void |
addListener(Player.Listener listener)Calls |
void |
addMediaItem(MediaItem mediaItem)Calls |
void |
addMediaItem(int index, MediaItem mediaItem)Calls |
void |
addMediaItems(List<MediaItem> mediaItems)Calls |
void |
addMediaItems(int index, List<MediaItem> mediaItems)Calls |
boolean |
Calls |
void |
Calls |
void |
Calls |
void |
clearVideoSurface(@Nullable Surface surface)Calls |
void |
clearVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder)Calls |
void |
clearVideoSurfaceView(@Nullable SurfaceView surfaceView)Calls |
void |
clearVideoTextureView(@Nullable TextureView textureView)Calls |
void |
This method is deprecated. Use |
void |
decreaseDeviceVolume(@C.VolumeFlags int flags)Calls |
Looper |
Calls |
AudioAttributes |
Calls |
int |
Calls |
Player.Commands |
Calls |
int |
Calls |
long |
Calls |
long |
Calls |
long |
Calls |
long |
Calls |
int |
Calls |
int |
Calls |
CueGroup |
Calls |
long |
Calls |
@Nullable Object |
Calls |
@Nullable MediaItem |
Calls |
int |
Calls |
int |
Calls |
long |
Calls |
Timeline |
Calls |
Tracks |
Calls |
int |
This method is deprecated. Use |
DeviceInfo |
Calls |
int |
Calls |
long |
Calls |
long |
Calls |
MediaItem |
getMediaItemAt(int index)Calls |
int |
Calls |
MediaMetadata |
Calls |
int |
Calls |
int |
This method is deprecated. Use |
boolean |
Calls |
PlaybackParameters |
Calls |
int |
Calls |
int |
Calls |
@Nullable PlaybackException |
Calls |
MediaMetadata |
Calls |
int |
Calls |
int |
This method is deprecated. Use |
int |
Calls |
long |
Calls |
long |
Calls |
boolean |
Calls |
Size |
Calls |
long |
Calls |
TrackSelectionParameters |
Calls |
VideoSize |
Calls |
float |
Calls |
Player |
Returns the |
boolean |
Calls |
boolean |
Calls |
void |
This method is deprecated. Use |
void |
increaseDeviceVolume(@C.VolumeFlags int flags)Calls |
boolean |
isCommandAvailable(@Player.Command int command)Calls |
boolean |
Calls |
boolean |
Calls |
boolean |
Calls |
boolean |
This method is deprecated. Use |
boolean |
This method is deprecated. Use |
boolean |
This method is deprecated. Use |
boolean |
Calls |
boolean |
Calls |
boolean |
Calls |
boolean |
Calls |
void |
moveMediaItem(int currentIndex, int newIndex)Calls |
void |
moveMediaItems(int fromIndex, int toIndex, int newIndex)Calls |
void |
mute()Calls |
void |
pause()Calls |
void |
play()Calls |
void |
prepare()Calls |
void |
release()Calls |
void |
removeListener(Player.Listener listener)Calls |
void |
removeMediaItem(int index)Calls |
void |
removeMediaItems(int fromIndex, int toIndex)Calls |
void |
replaceMediaItem(int index, MediaItem mediaItem)Calls |
void |
replaceMediaItems(Calls |
void |
seekBack()Calls |
void |
Calls |
void |
seekTo(long positionMs)Calls |
void |
seekTo(int mediaItemIndex, long positionMs)Calls |
void |
Calls |
void |
seekToDefaultPosition(int mediaItemIndex)Calls |
void |
Calls |
void |
Calls |
void |
Calls |
void |
Calls |
void |
setAudioAttributes(Calls |
void |
This method is deprecated. Use |
void |
setDeviceMuted(boolean muted, @C.VolumeFlags int flags)Calls |
void |
This method is deprecated. Use |
void |
setDeviceVolume(int volume, @C.VolumeFlags int flags)Calls |
void |
setMediaItem(MediaItem mediaItem)Calls |
void |
setMediaItem(MediaItem mediaItem, boolean resetPosition)Calls |
void |
setMediaItem(MediaItem mediaItem, long startPositionMs)Calls |
void |
setMediaItems(List<MediaItem> mediaItems)Calls |
void |
setMediaItems(List<MediaItem> mediaItems, boolean resetPosition)Calls |
void |
setMediaItems(Calls |
void |
setPlayWhenReady(boolean playWhenReady)Calls |
void |
setPlaybackParameters(PlaybackParameters playbackParameters)Calls |
void |
setPlaybackSpeed(float speed)Calls |
void |
setPlaylistMetadata(MediaMetadata mediaMetadata)Calls |
void |
setRepeatMode(@Player.RepeatMode int repeatMode)Calls |
void |
setShuffleModeEnabled(boolean shuffleModeEnabled)Calls |
void |
setTrackSelectionParameters(TrackSelectionParameters parameters)Calls |
void |
setVideoSurface(@Nullable Surface surface)Calls |
void |
setVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder)Calls |
void |
setVideoSurfaceView(@Nullable SurfaceView surfaceView)Calls |
void |
setVideoTextureView(@Nullable TextureView textureView)Calls |
void |
setVolume(float volume)Calls |
void |
stop()Calls |
void |
unmute()Calls |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
ForwardingPlayer
public ForwardingPlayer(Player player)
Creates a new instance that forwards all operations to player.
Public methods
addListener
public void addListener(Player.Listener listener)
Calls addListener on the delegate.
Overrides of this method must not directly call
delegate.addListener. If the override wants to pass the Player.Listener instance to the delegate Player, it must do so by calling super.addListener instead. This ensures the correct Player instance is passed to onEvents (i.e. this forwarding instance, and not the underlying delegate instance).
addMediaItem
public void addMediaItem(int index, MediaItem mediaItem)
Calls addMediaItem on the delegate.
addMediaItems
public void addMediaItems(List<MediaItem> mediaItems)
Calls addMediaItems on the delegate.
addMediaItems
public void addMediaItems(int index, List<MediaItem> mediaItems)
Calls addMediaItems on the delegate.
canAdvertiseSession
public boolean canAdvertiseSession()
Calls canAdvertiseSession on the delegate and returns the result.
clearVideoSurface
public void clearVideoSurface(@Nullable Surface surface)
Calls clearVideoSurface on the delegate.
clearVideoSurfaceHolder
public void clearVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder)
Calls clearVideoSurfaceHolder on the delegate.
clearVideoSurfaceView
public void clearVideoSurfaceView(@Nullable SurfaceView surfaceView)
Calls clearVideoSurfaceView on the delegate.
clearVideoTextureView
public void clearVideoTextureView(@Nullable TextureView textureView)
Calls clearVideoTextureView on the delegate.
decreaseDeviceVolume
public void decreaseDeviceVolume(@C.VolumeFlags int flags)
Calls decreaseDeviceVolume on the delegate.
getApplicationLooper
public Looper getApplicationLooper()
Calls getApplicationLooper on the delegate and returns the result.
getAudioAttributes
public AudioAttributes getAudioAttributes()
Calls getAudioAttributes on the delegate and returns the result.
getAudioSessionId
public int getAudioSessionId()
Calls getAudioSessionId on the delegate and returns the result.
getAvailableCommands
public Player.Commands getAvailableCommands()
Calls getAvailableCommands on the delegate and returns the result.
getBufferedPercentage
public int getBufferedPercentage()
Calls getBufferedPercentage on the delegate and returns the result.
getBufferedPosition
public long getBufferedPosition()
Calls getBufferedPosition on the delegate and returns the result.
getContentBufferedPosition
public long getContentBufferedPosition()
Calls getContentBufferedPosition on the delegate and returns the result.
getContentDuration
public long getContentDuration()
Calls getContentDuration on the delegate and returns the result.
getContentPosition
public long getContentPosition()
Calls getContentPosition on the delegate and returns the result.
getCurrentAdGroupIndex
public int getCurrentAdGroupIndex()
Calls getCurrentAdGroupIndex on the delegate and returns the result.
getCurrentAdIndexInAdGroup
public int getCurrentAdIndexInAdGroup()
Calls getCurrentAdIndexInAdGroup on the delegate and returns the result.
getCurrentCues
public CueGroup getCurrentCues()
Calls getCurrentCues on the delegate and returns the result.
getCurrentLiveOffset
public long getCurrentLiveOffset()
Calls getCurrentLiveOffset on the delegate and returns the result.
getCurrentManifest
public @Nullable Object getCurrentManifest()
Calls getCurrentManifest on the delegate and returns the result.
getCurrentMediaItem
public @Nullable MediaItem getCurrentMediaItem()
Calls getCurrentMediaItem on the delegate and returns the result.
getCurrentMediaItemIndex
public int getCurrentMediaItemIndex()
Calls getCurrentMediaItemIndex on the delegate and returns the result.
getCurrentPeriodIndex
public int getCurrentPeriodIndex()
Calls getCurrentPeriodIndex on the delegate and returns the result.
getCurrentPosition
public long getCurrentPosition()
Calls getCurrentPosition on the delegate and returns the result.
getCurrentTimeline
public Timeline getCurrentTimeline()
Calls getCurrentTimeline on the delegate and returns the result.
getCurrentTracks
public Tracks getCurrentTracks()
Calls getCurrentTracks on the delegate and returns the result.
getCurrentWindowIndex
public int getCurrentWindowIndex()Calls getCurrentWindowIndex on the delegate and returns the result.
getDeviceInfo
public DeviceInfo getDeviceInfo()
Calls getDeviceInfo on the delegate and returns the result.
getDeviceVolume
public int getDeviceVolume()
Calls getDeviceVolume on the delegate and returns the result.
getMaxSeekToPreviousPosition
public long getMaxSeekToPreviousPosition()
Calls getMaxSeekToPreviousPosition on the delegate and returns the result.
getMediaItemAt
public MediaItem getMediaItemAt(int index)
Calls getMediaItemAt on the delegate and returns the result.
getMediaItemCount
public int getMediaItemCount()
Calls getMediaItemCount on the delegate and returns the result.
getMediaMetadata
public MediaMetadata getMediaMetadata()
Calls getMediaMetadata on the delegate and returns the result.
getNextMediaItemIndex
public int getNextMediaItemIndex()
Calls getNextMediaItemIndex on the delegate and returns the result.
getNextWindowIndex
public int getNextWindowIndex()Calls getNextWindowIndex on the delegate and returns the result.
getPlayWhenReady
public boolean getPlayWhenReady()
Calls getPlayWhenReady on the delegate and returns the result.
getPlaybackParameters
public PlaybackParameters getPlaybackParameters()
Calls getPlaybackParameters on the delegate and returns the result.
getPlaybackState
public int getPlaybackState()
Calls getPlaybackState on the delegate and returns the result.
getPlaybackSuppressionReason
public int getPlaybackSuppressionReason()
Calls getPlaybackSuppressionReason on the delegate and returns the result.
getPlayerError
public @Nullable PlaybackException getPlayerError()
Calls getPlayerError on the delegate and returns the result.
getPlaylistMetadata
public MediaMetadata getPlaylistMetadata()
Calls getPlaylistMetadata on the delegate and returns the result.
getPreviousMediaItemIndex
public int getPreviousMediaItemIndex()
Calls getPreviousMediaItemIndex on the delegate and returns the result.
getPreviousWindowIndex
public int getPreviousWindowIndex()Calls getPreviousWindowIndex on the delegate and returns the result.
getRepeatMode
public int getRepeatMode()
Calls getRepeatMode on the delegate and returns the result.
getSeekBackIncrement
public long getSeekBackIncrement()
Calls getSeekBackIncrement on the delegate and returns the result.
getSeekForwardIncrement
public long getSeekForwardIncrement()
Calls getSeekForwardIncrement on the delegate and returns the result.
getShuffleModeEnabled
public boolean getShuffleModeEnabled()
Calls getShuffleModeEnabled on the delegate and returns the result.
getSurfaceSize
public Size getSurfaceSize()
Calls getSurfaceSize on the delegate and returns the result.
getTotalBufferedDuration
public long getTotalBufferedDuration()
Calls getTotalBufferedDuration on the delegate and returns the result.
getTrackSelectionParameters
public TrackSelectionParameters getTrackSelectionParameters()
Calls getTrackSelectionParameters on the delegate and returns the result.
getVideoSize
public VideoSize getVideoSize()
Calls getVideoSize on the delegate and returns the result.
getWrappedPlayer
public Player getWrappedPlayer()
Returns the Player to which operations are forwarded.
hasNextMediaItem
public boolean hasNextMediaItem()
Calls hasNextMediaItem on the delegate and returns the result.
hasPreviousMediaItem
public boolean hasPreviousMediaItem()
Calls hasPreviousMediaItem on the delegate and returns the result.
increaseDeviceVolume
public void increaseDeviceVolume(@C.VolumeFlags int flags)
Calls increaseDeviceVolume on the delegate.
isCommandAvailable
public boolean isCommandAvailable(@Player.Command int command)
Calls isCommandAvailable on the delegate and returns the result.
isCurrentMediaItemDynamic
public boolean isCurrentMediaItemDynamic()
Calls isCurrentMediaItemDynamic on the delegate and returns the result.
isCurrentMediaItemLive
public boolean isCurrentMediaItemLive()
Calls isCurrentMediaItemLive on the delegate and returns the result.
isCurrentMediaItemSeekable
public boolean isCurrentMediaItemSeekable()
Calls isCurrentMediaItemSeekable on the delegate and returns the result.
isCurrentWindowDynamic
public boolean isCurrentWindowDynamic()Calls isCurrentWindowDynamic on the delegate and returns the result.
isCurrentWindowLive
public boolean isCurrentWindowLive()Calls isCurrentWindowLive on the delegate and returns the result.
isCurrentWindowSeekable
public boolean isCurrentWindowSeekable()Calls isCurrentWindowSeekable on the delegate and returns the result.
isDeviceMuted
public boolean isDeviceMuted()
Calls isDeviceMuted on the delegate and returns the result.
moveMediaItem
public void moveMediaItem(int currentIndex, int newIndex)
Calls moveMediaItem on the delegate.
moveMediaItems
public void moveMediaItems(int fromIndex, int toIndex, int newIndex)
Calls moveMediaItems on the delegate.
removeListener
public void removeListener(Player.Listener listener)
Calls removeListener on the delegate.
Overrides of this method must not directly call
delegate.removeListener. If the override wants to pass the Player.Listener instance to the delegate Player, it must do so by calling super.removeListener instead.
removeMediaItems
public void removeMediaItems(int fromIndex, int toIndex)
Calls removeMediaItems on the delegate.
replaceMediaItem
public void replaceMediaItem(int index, MediaItem mediaItem)
Calls replaceMediaItem on the delegate.
replaceMediaItems
public void replaceMediaItems(
int fromIndex,
int toIndex,
List<MediaItem> mediaItems
)
Calls replaceMediaItems on the delegate.
seekToDefaultPosition
public void seekToDefaultPosition()
Calls seekToDefaultPosition on the delegate.
seekToDefaultPosition
public void seekToDefaultPosition(int mediaItemIndex)
Calls seekToDefaultPosition on the delegate.
seekToPreviousMediaItem
public void seekToPreviousMediaItem()
Calls seekToPreviousMediaItem on the delegate.
setAudioAttributes
public void setAudioAttributes(
AudioAttributes audioAttributes,
boolean handleAudioFocus
)
Calls setAudioAttributes on the delegate.
setDeviceMuted
public void setDeviceMuted(boolean muted, @C.VolumeFlags int flags)
Calls setDeviceMuted on the delegate.
setDeviceVolume
public void setDeviceVolume(int volume, @C.VolumeFlags int flags)
Calls setDeviceVolume on the delegate.
setMediaItem
public void setMediaItem(MediaItem mediaItem, boolean resetPosition)
Calls setMediaItem on the delegate.
setMediaItem
public void setMediaItem(MediaItem mediaItem, long startPositionMs)
Calls setMediaItem on the delegate.
setMediaItems
public void setMediaItems(List<MediaItem> mediaItems)
Calls setMediaItems on the delegate.
setMediaItems
public void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition)
Calls setMediaItems ()} on the delegate.
setMediaItems
public void setMediaItems(
List<MediaItem> mediaItems,
int startIndex,
long startPositionMs
)
Calls setMediaItems on the delegate.
setPlayWhenReady
public void setPlayWhenReady(boolean playWhenReady)
Calls setPlayWhenReady on the delegate.
setPlaybackParameters
public void setPlaybackParameters(PlaybackParameters playbackParameters)
Calls setPlaybackParameters on the delegate.
setPlaylistMetadata
public void setPlaylistMetadata(MediaMetadata mediaMetadata)
Calls setPlaylistMetadata on the delegate.
setRepeatMode
public void setRepeatMode(@Player.RepeatMode int repeatMode)
Calls setRepeatMode on the delegate.
setShuffleModeEnabled
public void setShuffleModeEnabled(boolean shuffleModeEnabled)
Calls setShuffleModeEnabled on the delegate.
setTrackSelectionParameters
public void setTrackSelectionParameters(TrackSelectionParameters parameters)
Calls setTrackSelectionParameters on the delegate.
setVideoSurface
public void setVideoSurface(@Nullable Surface surface)
Calls setVideoSurface on the delegate.
setVideoSurfaceHolder
public void setVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder)
Calls setVideoSurfaceHolder on the delegate.
setVideoSurfaceView
public void setVideoSurfaceView(@Nullable SurfaceView surfaceView)
Calls setVideoSurfaceView on the delegate.
setVideoTextureView
public void setVideoTextureView(@Nullable TextureView textureView)
Calls setVideoTextureView on the delegate.