ExoPlayer, Player, Player.AudioComponent, Player.DeviceComponent, Player.MetadataComponent, Player.TextComponent, Player.VideoComponentpublic class SimpleExoPlayer extends BasePlayer implements ExoPlayer, Player.AudioComponent, Player.VideoComponent, Player.TextComponent, Player.MetadataComponent, Player.DeviceComponent
ExoPlayer implementation that uses default Renderer components. Instances can
be obtained from SimpleExoPlayer.Builder.| Modifier and Type | Class | Description |
|---|---|---|
static class |
SimpleExoPlayer.Builder |
A builder for
SimpleExoPlayer instances. |
Player.AudioComponent, Player.DefaultEventListener, Player.DeviceComponent, Player.DiscontinuityReason, Player.EventFlags, Player.EventListener, Player.Events, Player.MediaItemTransitionReason, Player.MetadataComponent, Player.PlaybackSuppressionReason, Player.PlayWhenReadyChangeReason, Player.RepeatMode, Player.State, Player.TextComponent, Player.TimelineChangeReason, Player.VideoComponent| Modifier and Type | Field | Description |
|---|---|---|
static long |
DEFAULT_DETACH_SURFACE_TIMEOUT_MS |
The default timeout for detaching a surface from the player, in milliseconds.
|
protected Renderer[] |
renderers |
windowDEFAULT_RELEASE_TIMEOUT_MSDISCONTINUITY_REASON_AD_INSERTION, DISCONTINUITY_REASON_INTERNAL, DISCONTINUITY_REASON_PERIOD_TRANSITION, DISCONTINUITY_REASON_SEEK, DISCONTINUITY_REASON_SEEK_ADJUSTMENT, EVENT_IS_LOADING_CHANGED, EVENT_IS_PLAYING_CHANGED, EVENT_MEDIA_ITEM_TRANSITION, EVENT_PLAY_WHEN_READY_CHANGED, EVENT_PLAYBACK_PARAMETERS_CHANGED, EVENT_PLAYBACK_STATE_CHANGED, EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED, EVENT_PLAYER_ERROR, EVENT_POSITION_DISCONTINUITY, EVENT_REPEAT_MODE_CHANGED, EVENT_SHUFFLE_MODE_ENABLED_CHANGED, EVENT_STATIC_METADATA_CHANGED, EVENT_TIMELINE_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| Modifier | Constructor | Description |
|---|---|---|
protected |
SimpleExoPlayer(Context context,
RenderersFactory renderersFactory,
TrackSelector trackSelector,
MediaSourceFactory mediaSourceFactory,
LoadControl loadControl,
BandwidthMeter bandwidthMeter,
AnalyticsCollector analyticsCollector,
boolean useLazyPreparation,
Clock clock,
Looper applicationLooper) |
Deprecated.
Use the
SimpleExoPlayer.Builder and pass it to SimpleExoPlayer(Builder). |
protected |
SimpleExoPlayer(SimpleExoPlayer.Builder builder) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
addAnalyticsListener(AnalyticsListener listener) |
Adds an
AnalyticsListener to receive analytics events. |
void |
addAudioListener(AudioListener listener) |
Adds a listener to receive audio events.
|
void |
addDeviceListener(DeviceListener listener) |
Adds a listener to receive device events.
|
void |
addListener(Player.EventListener listener) |
Register a listener to receive events from the player.
|
void |
addMediaItem(int index,
MediaItem mediaItem) |
Adds a media item at the given index of the playlist.
|
void |
addMediaItem(MediaItem mediaItem) |
Adds a media item to the end of the playlist.
|
void |
addMediaItems(int index,
List<MediaItem> mediaItems) |
Adds a list of media items at the given index of the playlist.
|
void |
addMediaItems(List<MediaItem> mediaItems) |
Adds a list of media items to the end of the playlist.
|
void |
addMediaSource(int index,
MediaSource mediaSource) |
Adds a media source at the given index of the playlist.
|
void |
addMediaSource(MediaSource mediaSource) |
Adds a media source to the end of the playlist.
|
void |
addMediaSources(int index,
List<MediaSource> mediaSources) |
Adds a list of media sources at the given index of the playlist.
|
void |
addMediaSources(List<MediaSource> mediaSources) |
Adds a list of media sources to the end of the playlist.
|
void |
addMetadataOutput(MetadataOutput listener) |
Adds a
MetadataOutput to receive metadata. |
void |
addTextOutput(TextOutput listener) |
Registers an output to receive text events.
|
void |
addVideoListener(VideoListener listener) |
Adds a listener to receive video events.
|
void |
clearAuxEffectInfo() |
Detaches any previously attached auxiliary audio effect from the underlying audio track.
|
void |
clearCameraMotionListener(CameraMotionListener listener) |
Clears the listener which receives camera motion events if it matches the one passed.
|
void |
clearMediaItems() |
Clears the playlist.
|
void |
clearVideoFrameMetadataListener(VideoFrameMetadataListener listener) |
Clears the listener which receives video frame metadata events if it matches the one passed.
|
void |
clearVideoSurface() |
|
void |
clearVideoSurface(Surface surface) |
Clears the
Surface onto which video is being rendered if it matches the one passed. |
void |
clearVideoSurfaceHolder(SurfaceHolder surfaceHolder) |
Clears the
SurfaceHolder that holds the Surface onto which video is being
rendered if it matches the one passed. |
void |
clearVideoSurfaceView(SurfaceView surfaceView) |
Clears the
SurfaceView onto which video is being rendered if it matches the one
passed. |
void |
clearVideoTextureView(TextureView textureView) |
Clears the
TextureView onto which video is being rendered if it matches the one
passed. |
PlayerMessage |
createMessage(PlayerMessage.Target target) |
Creates a message that can be sent to a
PlayerMessage.Target. |
void |
decreaseDeviceVolume() |
Decreases the volume of the device.
|
boolean |
experimentalIsSleepingForOffload() |
Returns whether the player has paused its main loop to save power in offload scheduling mode.
|
void |
experimentalSetOffloadSchedulingEnabled(boolean offloadSchedulingEnabled) |
Sets whether audio offload scheduling is enabled.
|
AnalyticsCollector |
getAnalyticsCollector() |
Returns the
AnalyticsCollector used for collecting analytics events. |
Looper |
getApplicationLooper() |
Returns the
Looper associated with the application thread that's used to access the
player and on which player events are received. |
AudioAttributes |
getAudioAttributes() |
Returns the attributes for audio playback.
|
Player.AudioComponent |
getAudioComponent() |
Returns the component of this player for audio output, or null if audio is not supported.
|
DecoderCounters |
getAudioDecoderCounters() |
Returns
DecoderCounters for audio, or null if no audio is being played. |
Format |
getAudioFormat() |
Returns the audio format currently being played, or null if no audio is being played.
|
int |
getAudioSessionId() |
Returns the audio session identifier, or
C.AUDIO_SESSION_ID_UNSET if not set. |
long |
getBufferedPosition() |
Returns an estimate of the position in the current content window or ad up to which data is
buffered, in milliseconds.
|
Clock |
getClock() |
Returns the
Clock used for playback. |
long |
getContentBufferedPosition() |
If
Player.isPlayingAd() returns true, returns an estimate of the content position in
the current content window up to which data is buffered, in milliseconds. |
long |
getContentPosition() |
If
Player.isPlayingAd() returns true, returns the content position that will be
played once all ads in the ad group have finished playing, in milliseconds. |
int |
getCurrentAdGroupIndex() |
If
Player.isPlayingAd() returns true, returns the index of the ad group in the period
currently being played. |
int |
getCurrentAdIndexInAdGroup() |
If
Player.isPlayingAd() returns true, returns the index of the ad in its ad group. |
List<Cue> |
getCurrentCues() |
Returns the current
Cues. |
int |
getCurrentPeriodIndex() |
Returns the index of the period currently being played.
|
long |
getCurrentPosition() |
Returns the playback position in the current content window or ad, in milliseconds, or the
prospective position in milliseconds if the
current timeline is
empty. |
List<Metadata> |
getCurrentStaticMetadata() |
Returns the current static metadata for the track selections.
|
Timeline |
getCurrentTimeline() |
Returns the current
Timeline. |
TrackGroupArray |
getCurrentTrackGroups() |
Returns the available track groups.
|
TrackSelectionArray |
getCurrentTrackSelections() |
Returns the current track selections for each renderer.
|
int |
getCurrentWindowIndex() |
Returns the index of the current
window in the timeline, or the prospective window index if the current timeline is empty. |
Player.DeviceComponent |
getDeviceComponent() |
Returns the component of this player for playback device, or null if it's not supported.
|
DeviceInfo |
getDeviceInfo() |
Gets the device information.
|
int |
getDeviceVolume() |
Gets the current volume of the device.
|
long |
getDuration() |
Returns the duration of the current content window or ad in milliseconds, or
C.TIME_UNSET if the duration is not known. |
Player.MetadataComponent |
getMetadataComponent() |
Returns the component of this player for metadata output, or null if metadata is not supported.
|
boolean |
getPauseAtEndOfMediaItems() |
Returns whether the player pauses playback at the end of each media item.
|
ExoPlaybackException |
getPlaybackError() |
Deprecated.
Use
getPlayerError() instead. |
Looper |
getPlaybackLooper() |
Returns the
Looper associated with the playback thread. |
PlaybackParameters |
getPlaybackParameters() |
Returns the currently active playback parameters.
|
int |
getPlaybackState() |
Returns the current
playback state of the player. |
int |
getPlaybackSuppressionReason() |
Returns the reason why playback is suppressed even though
Player.getPlayWhenReady() is
true, or Player.PLAYBACK_SUPPRESSION_REASON_NONE if playback is not suppressed. |
ExoPlaybackException |
getPlayerError() |
Returns the error that caused playback to fail.
|
boolean |
getPlayWhenReady() |
Whether playback will proceed when
Player.getPlaybackState() == Player.STATE_READY. |
int |
getRendererCount() |
Returns the number of renderers.
|
int |
getRendererType(int index) |
Returns the track type that the renderer at a given index handles.
|
int |
getRepeatMode() |
Returns the current
Player.RepeatMode used for playback. |
SeekParameters |
getSeekParameters() |
Returns the currently active
SeekParameters of the player. |
boolean |
getShuffleModeEnabled() |
Returns whether shuffling of windows is enabled.
|
boolean |
getSkipSilenceEnabled() |
Returns whether skipping silences in the audio stream is enabled.
|
Player.TextComponent |
getTextComponent() |
Returns the component of this player for text output, or null if text is not supported.
|
long |
getTotalBufferedDuration() |
Returns an estimate of the total buffered duration from the current position, in milliseconds.
|
TrackSelector |
getTrackSelector() |
Returns the track selector that this player uses, or null if track selection is not supported.
|
Player.VideoComponent |
getVideoComponent() |
Returns the component of this player for video output, or null if video is not supported.
|
DecoderCounters |
getVideoDecoderCounters() |
Returns
DecoderCounters for video, or null if no video is being played. |
Format |
getVideoFormat() |
Returns the video format currently being played, or null if no video is being played.
|
int |
getVideoScalingMode() |
Returns the
C.VideoScalingMode. |
float |
getVolume() |
Returns the audio volume, with 0 being silence and 1 being unity gain.
|
void |
increaseDeviceVolume() |
Increases the volume of the device.
|
boolean |
isDeviceMuted() |
Gets whether the device is muted or not.
|
boolean |
isLoading() |
Whether the player is currently loading the source.
|
boolean |
isPlayingAd() |
Returns whether the player is currently playing an ad.
|
void |
moveMediaItem(int currentIndex,
int newIndex) |
Moves the media item at the current index to the new index.
|
void |
moveMediaItems(int fromIndex,
int toIndex,
int newIndex) |
Moves the media item range to the new index.
|
void |
prepare() |
Prepares the player.
|
void |
prepare(MediaSource mediaSource) |
Deprecated.
Use
setMediaSource(MediaSource) and Player.prepare() instead. |
void |
prepare(MediaSource mediaSource,
boolean resetPosition,
boolean resetState) |
Deprecated.
Use
setMediaSource(MediaSource, boolean) and Player.prepare()
instead. |
void |
release() |
Releases the player.
|
void |
removeAnalyticsListener(AnalyticsListener listener) |
Removes an
AnalyticsListener. |
void |
removeAudioListener(AudioListener listener) |
Removes a listener of audio events.
|
void |
removeDeviceListener(DeviceListener listener) |
Removes a listener of device events.
|
void |
removeListener(Player.EventListener listener) |
Unregister a listener.
|
void |
removeMediaItem(int index) |
Removes the media item at the given index of the playlist.
|
void |
removeMediaItems(int fromIndex,
int toIndex) |
Removes a range of media items from the playlist.
|
void |
removeMetadataOutput(MetadataOutput listener) |
Removes a
MetadataOutput. |
void |
removeTextOutput(TextOutput listener) |
Removes a text output.
|
void |
removeVideoListener(VideoListener listener) |
Removes a listener of video events.
|
void |
retry() |
Deprecated.
Use
prepare() instead. |
void |
seekTo(int windowIndex,
long positionMs) |
Seeks to a position specified in milliseconds in the specified window.
|
void |
setAudioAttributes(AudioAttributes audioAttributes,
boolean handleAudioFocus) |
Sets the attributes for audio playback, used by the underlying audio track.
|
void |
setAudioSessionId(int audioSessionId) |
Sets the ID of the audio session to attach to the underlying
AudioTrack. |
void |
setAuxEffectInfo(AuxEffectInfo auxEffectInfo) |
Sets information on an auxiliary audio effect to attach to the underlying audio track.
|
void |
setCameraMotionListener(CameraMotionListener listener) |
Sets a listener of camera motion events.
|
void |
setDeviceMuted(boolean muted) |
Sets the mute state of the device.
|
void |
setDeviceVolume(int volume) |
Sets the volume of the device.
|
void |
setForegroundMode(boolean foregroundMode) |
Sets whether the player is allowed to keep holding limited resources such as video decoders,
even when in the idle state.
|
void |
setHandleAudioBecomingNoisy(boolean handleAudioBecomingNoisy) |
Sets whether the player should pause automatically when audio is rerouted from a headset to
device speakers.
|
void |
setHandleWakeLock(boolean handleWakeLock) |
Deprecated.
Use
setWakeMode(int) instead. |
void |
setMediaItem(MediaItem mediaItem) |
Clears the playlist, adds the specified
MediaItem and resets the position to the
default position. |
void |
setMediaItem(MediaItem mediaItem,
boolean resetPosition) |
Clears the playlist and adds the specified
MediaItem. |
void |
setMediaItem(MediaItem mediaItem,
long startPositionMs) |
Clears the playlist and adds the specified
MediaItem. |
void |
setMediaItems(List<MediaItem> mediaItems) |
Clears the playlist, adds the specified
MediaItems and resets the position to
the default position. |
void |
setMediaItems(List<MediaItem> mediaItems,
boolean resetPosition) |
Clears the playlist and adds the specified
MediaItems. |
void |
setMediaItems(List<MediaItem> mediaItems,
int startWindowIndex,
long startPositionMs) |
Clears the playlist and adds the specified
MediaItems. |
void |
setMediaSource(MediaSource mediaSource) |
Clears the playlist, adds the specified
MediaSource and resets the position to the
default position. |
void |
setMediaSource(MediaSource mediaSource,
boolean resetPosition) |
Clears the playlist and adds the specified
MediaSource. |
void |
setMediaSource(MediaSource mediaSource,
long startPositionMs) |
Clears the playlist and adds the specified
MediaSource. |
void |
setMediaSources(List<MediaSource> mediaSources) |
Clears the playlist, adds the specified
MediaSources and resets the
position to the default position. |
void |
setMediaSources(List<MediaSource> mediaSources,
boolean resetPosition) |
Clears the playlist and adds the specified
MediaSources. |
void |
setMediaSources(List<MediaSource> mediaSources,
int startWindowIndex,
long startPositionMs) |
Clears the playlist and adds the specified
MediaSources. |
void |
setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems) |
Sets whether to pause playback at the end of each media item.
|
void |
setPlaybackParameters(PlaybackParameters playbackParameters) |
Attempts to set the playback parameters.
|
void |
setPlayWhenReady(boolean playWhenReady) |
Sets whether playback should proceed when
Player.getPlaybackState() == Player.STATE_READY. |
void |
setPriorityTaskManager(PriorityTaskManager priorityTaskManager) |
Sets a
PriorityTaskManager, or null to clear a previously set priority task manager. |
void |
setRepeatMode(int repeatMode) |
Sets the
Player.RepeatMode to be used for playback. |
void |
setSeekParameters(SeekParameters seekParameters) |
Sets the parameters that control how seek operations are performed.
|
void |
setShuffleModeEnabled(boolean shuffleModeEnabled) |
Sets whether shuffling of windows is enabled.
|
void |
setShuffleOrder(ShuffleOrder shuffleOrder) |
Sets the shuffle order.
|
void |
setSkipSilenceEnabled(boolean skipSilenceEnabled) |
Sets whether skipping silences in the audio stream is enabled.
|
void |
setThrowsWhenUsingWrongThread(boolean throwsWhenUsingWrongThread) |
Sets whether the player should throw an
IllegalStateException when methods are called
from a thread other than the one associated with getApplicationLooper(). |
void |
setVideoFrameMetadataListener(VideoFrameMetadataListener listener) |
Sets a listener to receive video frame metadata events.
|
void |
setVideoScalingMode(int videoScalingMode) |
Sets the video scaling mode.
|
void |
setVideoSurface(Surface surface) |
Sets the
Surface onto which video will be rendered. |
void |
setVideoSurfaceHolder(SurfaceHolder surfaceHolder) |
Sets the
SurfaceHolder that holds the Surface onto which video will be
rendered. |
void |
setVideoSurfaceView(SurfaceView surfaceView) |
Sets the
SurfaceView onto which video will be rendered. |
void |
setVideoTextureView(TextureView textureView) |
Sets the
TextureView onto which video will be rendered. |
void |
setVolume(float audioVolume) |
Sets the audio volume, with 0 being silence and 1 being unity gain.
|
void |
setWakeMode(int wakeMode) |
Sets how the player should keep the device awake for playback when the screen is off.
|
void |
stop(boolean reset) |
getBufferedPercentage, getContentDuration, getCurrentLiveOffset, getCurrentManifest, getCurrentMediaItem, getCurrentTag, getMediaItemAt, getMediaItemCount, getNextWindowIndex, getPreviousWindowIndex, hasNext, hasPrevious, isCurrentWindowDynamic, isCurrentWindowLive, isCurrentWindowSeekable, isPlaying, next, pause, play, previous, seekTo, seekToDefaultPosition, seekToDefaultPosition, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBufferedPercentage, getContentDuration, getCurrentLiveOffset, getCurrentManifest, getCurrentMediaItem, getCurrentTag, getMediaItemAt, getMediaItemCount, getNextWindowIndex, getPreviousWindowIndex, hasNext, hasPrevious, isCurrentWindowDynamic, isCurrentWindowLive, isCurrentWindowSeekable, isPlaying, next, pause, play, previous, seekTo, seekToDefaultPosition, seekToDefaultPosition, stoppublic static final long DEFAULT_DETACH_SURFACE_TIMEOUT_MS
protected final Renderer[] renderers
@Deprecated protected SimpleExoPlayer(Context context, RenderersFactory renderersFactory, TrackSelector trackSelector, MediaSourceFactory mediaSourceFactory, LoadControl loadControl, BandwidthMeter bandwidthMeter, AnalyticsCollector analyticsCollector, boolean useLazyPreparation, Clock clock, Looper applicationLooper)
SimpleExoPlayer.Builder and pass it to SimpleExoPlayer(Builder).protected SimpleExoPlayer(SimpleExoPlayer.Builder builder)
builder - The SimpleExoPlayer.Builder to obtain all construction parameters.public void experimentalSetOffloadSchedulingEnabled(boolean offloadSchedulingEnabled)
ExoPlayerOnly use this scheduling mode if the player is not displaying anything to the user. For example when the application is in the background, or the screen is off. The player state (including position) is rarely updated (roughly between every 10 seconds and 1 minute).
While offload scheduling is enabled, player events may be delivered severely delayed and
apps should not interact with the player. When returning to the foreground, disable offload
scheduling and wait for Player.EventListener.onExperimentalOffloadSchedulingEnabledChanged(boolean) to be called with
offloadSchedulingEnabled = false before interacting with the player.
This mode should save significant power when the phone is playing offload audio with the screen off.
This mode only has an effect when playing an audio track in offload mode, which requires all the following:
DefaultRenderersFactory.setEnableAudioOffload(boolean) or the equivalent option passed to DefaultAudioSink(AudioCapabilities,
DefaultAudioSink.AudioProcessorChain, boolean, boolean, boolean).
AudioSink is playing with an offload AudioTrack.
The state where ExoPlayer main loop has been paused to save power during offload playback
can be queried with ExoPlayer.experimentalIsSleepingForOffload().
This method is experimental, and will be renamed or removed in a future release.
experimentalSetOffloadSchedulingEnabled in interface ExoPlayeroffloadSchedulingEnabled - Whether to enable offload scheduling.public boolean experimentalIsSleepingForOffload()
ExoPlayer@Nullable public Player.AudioComponent getAudioComponent()
PlayergetAudioComponent in interface Player@Nullable public Player.VideoComponent getVideoComponent()
PlayergetVideoComponent in interface Player@Nullable public Player.TextComponent getTextComponent()
PlayergetTextComponent in interface Player@Nullable public Player.MetadataComponent getMetadataComponent()
PlayergetMetadataComponent in interface Player@Nullable public Player.DeviceComponent getDeviceComponent()
PlayergetDeviceComponent in interface Playerpublic void setVideoScalingMode(@VideoScalingMode int videoScalingMode)
Note that the scaling mode only applies if a MediaCodec-based video Renderer
is enabled and if the output surface is owned by a SurfaceView.
setVideoScalingMode in interface Player.VideoComponentvideoScalingMode - The C.VideoScalingMode.@VideoScalingMode public int getVideoScalingMode()
Player.VideoComponentC.VideoScalingMode.getVideoScalingMode in interface Player.VideoComponentpublic void clearVideoSurface()
Player.VideoComponentclearVideoSurface in interface Player.VideoComponentpublic void clearVideoSurface(@Nullable
Surface surface)
Player.VideoComponentSurface onto which video is being rendered if it matches the one passed.
Else does nothing.clearVideoSurface in interface Player.VideoComponentsurface - The surface to clear.public void setVideoSurface(@Nullable
Surface surface)
Player.VideoComponentSurface onto which video will be rendered. The caller is responsible for
tracking the lifecycle of the surface, and must clear the surface by calling
setVideoSurface(null) if the surface is destroyed.
If the surface is held by a SurfaceView, TextureView or SurfaceHolder then it's recommended to use Player.VideoComponent.setVideoSurfaceView(SurfaceView), Player.VideoComponent.setVideoTextureView(TextureView) or Player.VideoComponent.setVideoSurfaceHolder(SurfaceHolder) rather
than this method, since passing the holder allows the player to track the lifecycle of the
surface automatically.
setVideoSurface in interface Player.VideoComponentsurface - The Surface.public void setVideoSurfaceHolder(@Nullable
SurfaceHolder surfaceHolder)
Player.VideoComponentSurfaceHolder that holds the Surface onto which video will be
rendered. The player will track the lifecycle of the surface automatically.setVideoSurfaceHolder in interface Player.VideoComponentsurfaceHolder - The surface holder.public void clearVideoSurfaceHolder(@Nullable
SurfaceHolder surfaceHolder)
Player.VideoComponentSurfaceHolder that holds the Surface onto which video is being
rendered if it matches the one passed. Else does nothing.clearVideoSurfaceHolder in interface Player.VideoComponentsurfaceHolder - The surface holder to clear.public void setVideoSurfaceView(@Nullable
SurfaceView surfaceView)
Player.VideoComponentSurfaceView onto which video will be rendered. The player will track the
lifecycle of the surface automatically.setVideoSurfaceView in interface Player.VideoComponentsurfaceView - The surface view.public void clearVideoSurfaceView(@Nullable
SurfaceView surfaceView)
Player.VideoComponentSurfaceView onto which video is being rendered if it matches the one
passed. Else does nothing.clearVideoSurfaceView in interface Player.VideoComponentsurfaceView - The texture view to clear.public void setVideoTextureView(@Nullable
TextureView textureView)
Player.VideoComponentTextureView onto which video will be rendered. The player will track the
lifecycle of the surface automatically.setVideoTextureView in interface Player.VideoComponenttextureView - The texture view.public void clearVideoTextureView(@Nullable
TextureView textureView)
Player.VideoComponentTextureView onto which video is being rendered if it matches the one
passed. Else does nothing.clearVideoTextureView in interface Player.VideoComponenttextureView - The texture view to clear.public void addAudioListener(AudioListener listener)
Player.AudioComponentaddAudioListener in interface Player.AudioComponentlistener - The listener to register.public void removeAudioListener(AudioListener listener)
Player.AudioComponentremoveAudioListener in interface Player.AudioComponentlistener - The listener to unregister.public void setAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus)
Player.AudioComponentSetting the audio attributes during playback may introduce a short gap in audio output as the audio track is recreated. A new audio session id will also be generated.
If tunneling is enabled by the track selector, the specified audio attributes will be ignored, but they will take effect if audio is later played without tunneling.
If the device is running a build before platform API version 21, audio attributes cannot
be set directly on the underlying audio track. In this case, the usage will be mapped onto an
equivalent stream type using Util.getStreamTypeForAudioUsage(int).
If audio focus should be handled, the AudioAttributes.usage must be C.USAGE_MEDIA or C.USAGE_GAME. Other usages will throw an IllegalArgumentException.
setAudioAttributes in interface Player.AudioComponentaudioAttributes - The attributes to use for audio playback.handleAudioFocus - True if the player should handle audio focus, false otherwise.public AudioAttributes getAudioAttributes()
Player.AudioComponentgetAudioAttributes in interface Player.AudioComponentpublic void setAudioSessionId(int audioSessionId)
Player.AudioComponentAudioTrack.
The audio session ID can be generated using C.generateAudioSessionIdV21(Context)
for API 21+.
setAudioSessionId in interface Player.AudioComponentaudioSessionId - The audio session ID, or C.AUDIO_SESSION_ID_UNSET if it should
be generated by the framework.public int getAudioSessionId()
Player.AudioComponentC.AUDIO_SESSION_ID_UNSET if not set.getAudioSessionId in interface Player.AudioComponentpublic void setAuxEffectInfo(AuxEffectInfo auxEffectInfo)
Player.AudioComponentsetAuxEffectInfo in interface Player.AudioComponentpublic void clearAuxEffectInfo()
Player.AudioComponentclearAuxEffectInfo in interface Player.AudioComponentpublic void setVolume(float audioVolume)
Player.AudioComponentsetVolume in interface Player.AudioComponentaudioVolume - The audio volume.public float getVolume()
Player.AudioComponentgetVolume in interface Player.AudioComponentpublic boolean getSkipSilenceEnabled()
Player.AudioComponentgetSkipSilenceEnabled in interface Player.AudioComponentpublic void setSkipSilenceEnabled(boolean skipSilenceEnabled)
Player.AudioComponentsetSkipSilenceEnabled in interface Player.AudioComponentskipSilenceEnabled - Whether skipping silences in the audio stream is enabled.public AnalyticsCollector getAnalyticsCollector()
AnalyticsCollector used for collecting analytics events.public void addAnalyticsListener(AnalyticsListener listener)
AnalyticsListener to receive analytics events.listener - The listener to be added.public void removeAnalyticsListener(AnalyticsListener listener)
AnalyticsListener.listener - The listener to be removed.public void setHandleAudioBecomingNoisy(boolean handleAudioBecomingNoisy)
handleAudioBecomingNoisy - Whether the player should pause automatically when audio is
rerouted from a headset to device speakers.public void setPriorityTaskManager(@Nullable
PriorityTaskManager priorityTaskManager)
PriorityTaskManager, or null to clear a previously set priority task manager.
The priority C.PRIORITY_PLAYBACK will be set while the player is loading.
priorityTaskManager - The PriorityTaskManager, or null to clear a previously set
priority task manager.@Nullable public Format getVideoFormat()
@Nullable public Format getAudioFormat()
@Nullable public DecoderCounters getVideoDecoderCounters()
DecoderCounters for video, or null if no video is being played.@Nullable public DecoderCounters getAudioDecoderCounters()
DecoderCounters for audio, or null if no audio is being played.public void addVideoListener(VideoListener listener)
Player.VideoComponentaddVideoListener in interface Player.VideoComponentlistener - The listener to register.public void removeVideoListener(VideoListener listener)
Player.VideoComponentremoveVideoListener in interface Player.VideoComponentlistener - The listener to unregister.public void setVideoFrameMetadataListener(VideoFrameMetadataListener listener)
Player.VideoComponentThis method is intended to be called by the same component that sets the Surface
onto which video will be rendered. If using ExoPlayer's standard UI components, this method
should not be called directly from application code.
setVideoFrameMetadataListener in interface Player.VideoComponentlistener - The listener.public void clearVideoFrameMetadataListener(VideoFrameMetadataListener listener)
Player.VideoComponentclearVideoFrameMetadataListener in interface Player.VideoComponentlistener - The listener to clear.public void setCameraMotionListener(CameraMotionListener listener)
Player.VideoComponentsetCameraMotionListener in interface Player.VideoComponentlistener - The listener.public void clearCameraMotionListener(CameraMotionListener listener)
Player.VideoComponentclearCameraMotionListener in interface Player.VideoComponentlistener - The listener to clear.public void addTextOutput(TextOutput listener)
Player.TextComponentaddTextOutput in interface Player.TextComponentlistener - The output to register.public void removeTextOutput(TextOutput listener)
Player.TextComponentremoveTextOutput in interface Player.TextComponentlistener - The output to remove.public List<Cue> getCurrentCues()
Player.TextComponentCues. This list may be empty.getCurrentCues in interface Player.TextComponentpublic void addMetadataOutput(MetadataOutput listener)
Player.MetadataComponentMetadataOutput to receive metadata.addMetadataOutput in interface Player.MetadataComponentlistener - The output to register.public void removeMetadataOutput(MetadataOutput listener)
Player.MetadataComponentMetadataOutput.removeMetadataOutput in interface Player.MetadataComponentlistener - The output to remove.public Looper getPlaybackLooper()
ExoPlayerLooper associated with the playback thread.getPlaybackLooper in interface ExoPlayerpublic Looper getApplicationLooper()
PlayerLooper associated with the application thread that's used to access the
player and on which player events are received.getApplicationLooper in interface Playerpublic Clock getClock()
ExoPlayerClock used for playback.public void addListener(Player.EventListener listener)
PlayerLooper, then the listener will be called on the main thread.addListener in interface Playerlistener - The listener to register.public void removeListener(Player.EventListener listener)
PlayerremoveListener in interface Playerlistener - The listener to unregister.@State public int getPlaybackState()
Playerplayback state of the player.getPlaybackState in interface Playerplayback state.Player.EventListener.onPlaybackStateChanged(int)@PlaybackSuppressionReason public int getPlaybackSuppressionReason()
PlayerPlayer.getPlayWhenReady() is
true, or Player.PLAYBACK_SUPPRESSION_REASON_NONE if playback is not suppressed.getPlaybackSuppressionReason in interface Playerplayback suppression reason.Player.EventListener.onPlaybackSuppressionReasonChanged(int)@Deprecated @Nullable public ExoPlaybackException getPlaybackError()
getPlayerError() instead.getPlaybackError in interface Player@Nullable public ExoPlaybackException getPlayerError()
PlayerPlayer.EventListener.onPlayerError(ExoPlaybackException) at the time of
failure. It can be queried using this method until the player is re-prepared.
Note that this method will always return null if Player.getPlaybackState() is not
Player.STATE_IDLE.
getPlayerError in interface Playernull.Player.EventListener.onPlayerError(ExoPlaybackException)@Deprecated public void retry()
prepare() instead.public void prepare()
Player@Deprecated public void prepare(MediaSource mediaSource)
setMediaSource(MediaSource) and Player.prepare() instead.@Deprecated public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState)
setMediaSource(MediaSource, boolean) and Player.prepare()
instead.public void setMediaItems(List<MediaItem> mediaItems)
PlayerMediaItems and resets the position to
the default position.setMediaItems in interface PlayersetMediaItems in class BasePlayermediaItems - The new MediaItems.public void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition)
PlayerMediaItems.setMediaItems in interface PlayermediaItems - The new MediaItems.resetPosition - Whether the playback position should be reset to the default position in
the first Timeline.Window. If false, playback will start from the position defined
by Player.getCurrentWindowIndex() and Player.getCurrentPosition().public void setMediaItems(List<MediaItem> mediaItems, int startWindowIndex, long startPositionMs)
PlayerMediaItems.setMediaItems in interface PlayermediaItems - The new MediaItems.startWindowIndex - The window index to start playback from. If C.INDEX_UNSET is
passed, the current position is not reset.startPositionMs - The position in milliseconds to start playback from. If C.TIME_UNSET is passed, the default position of the given window is used. In any case, if
startWindowIndex is set to C.INDEX_UNSET, this parameter is ignored and the
position is not reset at all.public void setMediaItem(MediaItem mediaItem)
PlayerMediaItem and resets the position to the
default position.setMediaItem in interface PlayersetMediaItem in class BasePlayermediaItem - The new MediaItem.public void setMediaItem(MediaItem mediaItem, boolean resetPosition)
PlayerMediaItem.setMediaItem in interface PlayersetMediaItem in class BasePlayermediaItem - The new MediaItem.resetPosition - Whether the playback position should be reset to the default position. If
false, playback will start from the position defined by Player.getCurrentWindowIndex()
and Player.getCurrentPosition().public void setMediaItem(MediaItem mediaItem, long startPositionMs)
PlayerMediaItem.setMediaItem in interface PlayersetMediaItem in class BasePlayermediaItem - The new MediaItem.startPositionMs - The position in milliseconds to start playback from.public void setMediaSources(List<MediaSource> mediaSources)
ExoPlayerMediaSources and resets the
position to the default position.setMediaSources in interface ExoPlayermediaSources - The new MediaSources.public void setMediaSources(List<MediaSource> mediaSources, boolean resetPosition)
ExoPlayerMediaSources.setMediaSources in interface ExoPlayermediaSources - The new MediaSources.resetPosition - Whether the playback position should be reset to the default position in
the first Timeline.Window. If false, playback will start from the position defined
by Player.getCurrentWindowIndex() and Player.getCurrentPosition().public void setMediaSources(List<MediaSource> mediaSources, int startWindowIndex, long startPositionMs)
ExoPlayerMediaSources.setMediaSources in interface ExoPlayermediaSources - The new MediaSources.startWindowIndex - The window index to start playback from. If C.INDEX_UNSET is
passed, the current position is not reset.startPositionMs - The position in milliseconds to start playback from. If C.TIME_UNSET is passed, the default position of the given window is used. In any case, if
startWindowIndex is set to C.INDEX_UNSET, this parameter is ignored and the
position is not reset at all.public void setMediaSource(MediaSource mediaSource)
ExoPlayerMediaSource and resets the position to the
default position.setMediaSource in interface ExoPlayermediaSource - The new MediaSource.public void setMediaSource(MediaSource mediaSource, boolean resetPosition)
ExoPlayerMediaSource.setMediaSource in interface ExoPlayermediaSource - The new MediaSource.resetPosition - Whether the playback position should be reset to the default position. If
false, playback will start from the position defined by Player.getCurrentWindowIndex()
and Player.getCurrentPosition().public void setMediaSource(MediaSource mediaSource, long startPositionMs)
ExoPlayerMediaSource.setMediaSource in interface ExoPlayermediaSource - The new MediaSource.startPositionMs - The position in milliseconds to start playback from.public void addMediaItems(List<MediaItem> mediaItems)
PlayeraddMediaItems in interface PlayermediaItems - The MediaItems to add.public void addMediaItems(int index,
List<MediaItem> mediaItems)
PlayeraddMediaItems in interface Playerindex - The index at which to add the media items.mediaItems - The MediaItems to add.public void addMediaItem(MediaItem mediaItem)
PlayeraddMediaItem in interface PlayeraddMediaItem in class BasePlayermediaItem - The MediaItem to add.public void addMediaItem(int index,
MediaItem mediaItem)
PlayeraddMediaItem in interface PlayeraddMediaItem in class BasePlayerindex - The index at which to add the item.mediaItem - The MediaItem to add.public void addMediaSource(MediaSource mediaSource)
ExoPlayeraddMediaSource in interface ExoPlayermediaSource - The MediaSource to add.public void addMediaSource(int index,
MediaSource mediaSource)
ExoPlayeraddMediaSource in interface ExoPlayerindex - The index at which to add the source.mediaSource - The MediaSource to add.public void addMediaSources(List<MediaSource> mediaSources)
ExoPlayeraddMediaSources in interface ExoPlayermediaSources - The MediaSources to add.public void addMediaSources(int index,
List<MediaSource> mediaSources)
ExoPlayeraddMediaSources in interface ExoPlayerindex - The index at which to add the media sources.mediaSources - The MediaSources to add.public void moveMediaItem(int currentIndex,
int newIndex)
PlayermoveMediaItem in interface PlayermoveMediaItem in class BasePlayercurrentIndex - 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.public void moveMediaItems(int fromIndex,
int toIndex,
int newIndex)
PlayermoveMediaItems in interface PlayerfromIndex - 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.public void removeMediaItem(int index)
PlayerremoveMediaItem in interface PlayerremoveMediaItem in class BasePlayerindex - The index at which to remove the media item.public void removeMediaItems(int fromIndex,
int toIndex)
PlayerremoveMediaItems in interface PlayerfromIndex - The index at which to start removing media items.toIndex - The index of the first item to be kept (exclusive).public void clearMediaItems()
PlayerclearMediaItems in interface Playerpublic void setShuffleOrder(ShuffleOrder shuffleOrder)
ExoPlayersetShuffleOrder in interface ExoPlayershuffleOrder - The shuffle order.public void setPlayWhenReady(boolean playWhenReady)
PlayerPlayer.getPlaybackState() == Player.STATE_READY.
If the player is already in the ready state then this method pauses and resumes playback.
setPlayWhenReady in interface PlayerplayWhenReady - Whether playback should proceed when ready.public boolean getPlayWhenReady()
PlayerPlayer.getPlaybackState() == Player.STATE_READY.getPlayWhenReady in interface PlayerPlayer.EventListener.onPlayWhenReadyChanged(boolean, int)public void setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems)
ExoPlayerThis means the player will pause at the end of each window in the current timeline. Listeners will be informed by a call to Player.EventListener.onPlayWhenReadyChanged(boolean, int) with the reason Player.PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM when this happens.
setPauseAtEndOfMediaItems in interface ExoPlayerpauseAtEndOfMediaItems - Whether to pause playback at the end of each media item.public boolean getPauseAtEndOfMediaItems()
ExoPlayergetPauseAtEndOfMediaItems in interface ExoPlayerExoPlayer.setPauseAtEndOfMediaItems(boolean)@RepeatMode public int getRepeatMode()
PlayerPlayer.RepeatMode used for playback.getRepeatMode in interface PlayerPlayer.EventListener.onRepeatModeChanged(int)public void setRepeatMode(@RepeatMode int repeatMode)
PlayerPlayer.RepeatMode to be used for playback.setRepeatMode in interface PlayerrepeatMode - The repeat mode.public void setShuffleModeEnabled(boolean shuffleModeEnabled)
PlayersetShuffleModeEnabled in interface PlayershuffleModeEnabled - Whether shuffling is enabled.public boolean getShuffleModeEnabled()
PlayergetShuffleModeEnabled in interface PlayerPlayer.EventListener.onShuffleModeEnabledChanged(boolean)public boolean isLoading()
PlayerisLoading in interface PlayerPlayer.EventListener.onIsLoadingChanged(boolean)public void seekTo(int windowIndex,
long positionMs)
PlayerseekTo in interface PlayerwindowIndex - The index of the window.positionMs - The seek position in the specified window, or C.TIME_UNSET to seek to
the window's default position.public void setPlaybackParameters(@Nullable
PlaybackParameters playbackParameters)
Playernull sets the parameters to the
default, PlaybackParameters.DEFAULT, which means there is no speed or pitch adjustment.
Playback parameters changes may cause the player to buffer. Player.EventListener.onPlaybackParametersChanged(PlaybackParameters) will be called whenever the
currently active playback parameters change.
setPlaybackParameters in interface PlayerplaybackParameters - The playback parameters, or null to use the defaults.public PlaybackParameters getPlaybackParameters()
PlayergetPlaybackParameters in interface PlayerPlayer.EventListener.onPlaybackParametersChanged(PlaybackParameters)public void setSeekParameters(@Nullable
SeekParameters seekParameters)
ExoPlayersetSeekParameters in interface ExoPlayerseekParameters - The seek parameters, or null to use the defaults.public SeekParameters getSeekParameters()
ExoPlayerSeekParameters of the player.getSeekParameters in interface ExoPlayerpublic void setForegroundMode(boolean foregroundMode)
ExoPlayerThis mode should be used with caution, since holding limited resources may prevent other players of media components from acquiring them. It should only be enabled when both of the following conditions are true:
Player.stop() is called to halt one playback, and
ExoPlayer.prepare(com.google.android.exoplayer2.source.MediaSource) is called some time later to start a new one).
Note that foreground mode is not useful for switching between content without gaps
between the playbacks. For this use case Player.stop() does not need to be called, and simply
calling ExoPlayer.prepare(com.google.android.exoplayer2.source.MediaSource) for the new media will cause limited resources to be retained even if
foreground mode is not enabled.
If foreground mode is enabled, it's the application's responsibility to disable it when the conditions described above no longer hold.
setForegroundMode in interface ExoPlayerforegroundMode - Whether the player is allowed to keep limited resources even when in the
idle state.public void release()
Playerpublic PlayerMessage createMessage(PlayerMessage.Target target)
ExoPlayerPlayerMessage.Target. By default, the message
will be delivered immediately without blocking on the playback thread. The default PlayerMessage.getType() is 0 and the default PlayerMessage.getPayload() is null. If a
position is specified with PlayerMessage.setPosition(long), the message will be
delivered at this position in the current window defined by Player.getCurrentWindowIndex().
Alternatively, the message can be sent at a specific window using PlayerMessage.setPosition(int, long).createMessage in interface ExoPlayerpublic int getRendererCount()
PlayergetRendererCount in interface Playerpublic int getRendererType(int index)
PlayerFor example, a video renderer will return C.TRACK_TYPE_VIDEO, an audio renderer will
return C.TRACK_TYPE_AUDIO and a text renderer will return C.TRACK_TYPE_TEXT.
getRendererType in interface Playerindex - The index of the renderer.TRACK_TYPE_* constants defined in C.@Nullable public TrackSelector getTrackSelector()
ExoPlayergetTrackSelector in interface ExoPlayerpublic TrackGroupArray getCurrentTrackGroups()
PlayergetCurrentTrackGroups in interface PlayerPlayer.EventListener.onTracksChanged(TrackGroupArray, TrackSelectionArray)public TrackSelectionArray getCurrentTrackSelections()
PlayerA 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.
getCurrentTrackSelections in interface Playerpublic List<Metadata> getCurrentStaticMetadata()
PlayerThe returned metadataList is an immutable list of Metadata instances, where
the elements correspond to the current track selections,
or an empty list if there are no track selections or the selected tracks contain no static
metadata.
This metadata is considered static in that it comes from the tracks' declared Formats, rather than being timed (or dynamic) metadata, which is represented within a metadata track.
getCurrentStaticMetadata in interface PlayerPlayer.EventListener.onStaticMetadataChanged(List)public Timeline getCurrentTimeline()
PlayerTimeline. Never null, but may be empty.getCurrentTimeline in interface PlayerPlayer.EventListener.onTimelineChanged(Timeline, int)public int getCurrentPeriodIndex()
PlayergetCurrentPeriodIndex in interface Playerpublic int getCurrentWindowIndex()
Playerwindow in the timeline, or the prospective window index if the current timeline is empty.getCurrentWindowIndex in interface Playerpublic long getDuration()
PlayerC.TIME_UNSET if the duration is not known.getDuration in interface Playerpublic long getCurrentPosition()
Playercurrent timeline is
empty.getCurrentPosition in interface Playerpublic long getBufferedPosition()
PlayergetBufferedPosition in interface Playerpublic long getTotalBufferedDuration()
PlayergetTotalBufferedDuration in interface Playerpublic boolean isPlayingAd()
PlayerisPlayingAd in interface Playerpublic int getCurrentAdGroupIndex()
PlayerPlayer.isPlayingAd() returns true, returns the index of the ad group in the period
currently being played. Returns C.INDEX_UNSET otherwise.getCurrentAdGroupIndex in interface Playerpublic int getCurrentAdIndexInAdGroup()
PlayerPlayer.isPlayingAd() returns true, returns the index of the ad in its ad group. Returns
C.INDEX_UNSET otherwise.getCurrentAdIndexInAdGroup in interface Playerpublic long getContentPosition()
PlayerPlayer.isPlayingAd() returns true, 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 by Player.getCurrentPosition().getContentPosition in interface Playerpublic long getContentBufferedPosition()
PlayerPlayer.isPlayingAd() returns true, returns an estimate of the content position in
the current content window up to which data is buffered, in milliseconds. If there is no ad
playing, the returned position is the same as that returned by Player.getBufferedPosition().getContentBufferedPosition in interface Player@Deprecated public void setHandleWakeLock(boolean handleWakeLock)
setWakeMode(int) instead.PowerManager.WakeLock to ensure the
device stays awake for playback, even when the screen is off.
Enabling this feature requires the Manifest.permission.WAKE_LOCK permission.
It should be used together with a foreground Service for use cases where
playback can occur when the screen is off (e.g. background audio playback). It is not useful if
the screen will always be on during playback (e.g. foreground video playback).
handleWakeLock - Whether the player should use a PowerManager.WakeLock
to ensure the device stays awake for playback, even when the screen is off.public void setWakeMode(@WakeMode int wakeMode)
Enabling this feature requires the Manifest.permission.WAKE_LOCK permission.
It should be used together with a foreground Service for use cases where
playback occurs and the screen is off (e.g. background audio playback). It is not useful when
the screen will be kept on during playback (e.g. foreground video playback).
When enabled, the locks (PowerManager.WakeLock / WifiManager.WifiLock) will be held whenever the player is in the Player.STATE_READY or Player.STATE_BUFFERING states with playWhenReady = true. The locks
held depends on the specified C.WakeMode.
wakeMode - The C.WakeMode option to keep the device awake during playback.public void addDeviceListener(DeviceListener listener)
Player.DeviceComponentaddDeviceListener in interface Player.DeviceComponentpublic void removeDeviceListener(DeviceListener listener)
Player.DeviceComponentremoveDeviceListener in interface Player.DeviceComponentpublic DeviceInfo getDeviceInfo()
Player.DeviceComponentgetDeviceInfo in interface Player.DeviceComponentpublic int getDeviceVolume()
Player.DeviceComponentFor devices with local playback, the volume
returned by this method varies according to the current stream type. The
stream type is determined by AudioAttributes.usage which can be converted to stream
type with Util.getStreamTypeForAudioUsage(int). The audio attributes can be set to
the player by calling Player.AudioComponent.setAudioAttributes(com.google.android.exoplayer2.audio.AudioAttributes, boolean).
For devices with remote playback, the volume of
the remote device is returned.
getDeviceVolume in interface Player.DeviceComponentpublic boolean isDeviceMuted()
Player.DeviceComponentisDeviceMuted in interface Player.DeviceComponentpublic void setDeviceVolume(int volume)
Player.DeviceComponentsetDeviceVolume in interface Player.DeviceComponentvolume - The volume to set.public void increaseDeviceVolume()
Player.DeviceComponentincreaseDeviceVolume in interface Player.DeviceComponentpublic void decreaseDeviceVolume()
Player.DeviceComponentdecreaseDeviceVolume in interface Player.DeviceComponentpublic void setDeviceMuted(boolean muted)
Player.DeviceComponentsetDeviceMuted in interface Player.DeviceComponentpublic void setThrowsWhenUsingWrongThread(boolean throwsWhenUsingWrongThread)
IllegalStateException when methods are called
from a thread other than the one associated with getApplicationLooper().
The default is true and this method will be removed in the future.
throwsWhenUsingWrongThread - Whether to throw when methods are called from a wrong thread.