StubExoPlayer
@UnstableApi
public class StubExoPlayer extends StubPlayer implements ExoPlayer
| java.lang.Object | |||
| ↳ | androidx.media3.common.BasePlayer | ||
| ↳ | androidx.media3.test.utils.StubPlayer | ||
| ↳ | androidx.media3.test.utils.StubExoPlayer |
An abstract ExoPlayer implementation that throws UnsupportedOperationException from every method.
Summary
Public constructors |
|---|
Public methods |
|
|---|---|
void |
addAnalyticsListener(AnalyticsListener listener)Adds an |
void |
Adds a listener to receive audio offload events. |
void |
addMediaSource(MediaSource mediaSource)Adds a media source to the end of the playlist. |
void |
addMediaSource(int index, MediaSource mediaSource)Adds a media source 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 |
addMediaSources(int index, List<MediaSource> mediaSources)Adds a list of media sources at the given index of the playlist. |
void |
Detaches any previously attached auxiliary audio effect from the underlying audio track. |
void |
Clears the listener which receives camera motion events if it matches the one passed. |
void |
Clears the listener which receives video frame metadata events if it matches the one passed. |
PlayerMessage |
createMessage(PlayerMessage.Target target)Creates a message that can be sent to a |
AnalyticsCollector |
Returns the |
@Nullable DecoderCounters |
Returns |
@Nullable Format |
Returns the audio format currently being played, or null if no audio is being played. |
int |
Returns the audio session identifier, or |
Clock |
getClock()Returns the |
TrackGroupArray |
This method is deprecated. Use |
TrackSelectionArray |
This method is deprecated. Use |
boolean |
Returns whether the player pauses playback at the end of each media item. |
Looper |
Returns the |
ExoPlaybackException |
Returns the error that caused playback to fail. |
ExoPlayer.PreloadConfiguration |
Returns the |
Renderer |
getRenderer(int index)Returns the renderer at the given index. |
int |
Returns the number of renderers. |
int |
getRendererType(int index)Returns the track type that the renderer at a given index handles. |
ScrubbingModeParameters |
Gets the parameters that control behavior in |
Renderer |
getSecondaryRenderer(int index)Returns the secondary renderer at the given index. |
SeekParameters |
Returns the currently active |
ShuffleOrder |
Returns the shuffle order. |
boolean |
Returns whether skipping silences in the audio stream is enabled. |
@Nullable TrackSelector |
Returns the track selector that this player uses, or null if track selection is not supported. |
int |
Returns the |
@Nullable DecoderCounters |
Returns |
@Nullable Format |
Returns the video format currently being played, or null if no video is being played. |
int |
Returns the |
boolean |
Returns whether |
boolean |
Returns whether the player is optimized for scrubbing (many frequent seeks). |
boolean |
Returns whether the player has paused its main loop to save power in offload scheduling mode. |
boolean |
Returns whether tunneling is enabled for the currently selected tracks. |
void |
This method is deprecated. Use |
void |
This method is deprecated. Use |
void |
removeAnalyticsListener(AnalyticsListener listener)Removes an |
void |
Removes a listener of audio offload events. |
void |
setAudioAttributes(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 |
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 |
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 |
setImageOutput(@Nullable ImageOutput imageOutput)Sets the |
void |
setMaxSeekToPreviousPositionMs(long maxSeekToPreviousPositionMs)Sets the maximum position for which |
void |
setMediaSource(MediaSource mediaSource)Clears the playlist, adds the specified |
void |
setMediaSource(MediaSource mediaSource, boolean resetPosition)Clears the playlist and adds the specified |
void |
setMediaSource(MediaSource mediaSource, long startPositionMs)Clears the playlist and adds the specified |
void |
setMediaSources(List<MediaSource> mediaSources)Clears the playlist, adds the specified |
void |
setMediaSources(List<MediaSource> mediaSources, boolean resetPosition)Clears the playlist and adds the specified |
void |
setMediaSources(Clears the playlist and adds the specified |
void |
setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems)Sets whether to pause playback at the end of each media item. |
void |
setPreferredAudioDevice(@Nullable AudioDeviceInfo audioDeviceInfo)Sets the preferred audio device. |
void |
setPreloadConfiguration(Sets the |
void |
setPriority(@C.Priority int priority)Sets the |
void |
setPriorityTaskManager(Sets a |
void |
setScrubbingModeEnabled(boolean scrubbingModeEnabled)Sets whether to optimize the player for scrubbing (many frequent seeks). |
void |
setScrubbingModeParameters(Sets the parameters that control behavior in |
void |
setSeekBackIncrementMs(long seekBackIncrementMs)Sets the |
void |
setSeekForwardIncrementMs(long seekForwardIncrementMs)Sets the |
void |
setSeekParameters(@Nullable SeekParameters seekParameters)Sets the parameters that control how seek operations are performed. |
void |
setShuffleOrder(ShuffleOrder shuffleOrder)Sets the shuffle order. |
void |
setSkipSilenceEnabled(boolean skipSilenceEnabled)Sets whether skipping silences in the audio stream is enabled. |
void |
setVideoChangeFrameRateStrategy(int videoChangeFrameRateStrategy)Sets a |
void |
setVideoEffects(List<Effect> videoEffects)Sets a |
void |
Sets a listener to receive video frame metadata events. |
void |
setVideoScalingMode(int videoScalingMode)Sets the |
void |
setVirtualDeviceId(int virtualDeviceId)Sets the virtual device id to be used for playback. |
void |
setWakeMode(int wakeMode)Sets how the player should keep the device awake for playback when the screen is off. |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Inherited fields |
||
|---|---|---|
|
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
Public methods
addAnalyticsListener
public void addAnalyticsListener(AnalyticsListener listener)
Adds an AnalyticsListener to receive analytics events.
This method can be called from any thread.
| Parameters | |
|---|---|
AnalyticsListener listener |
The listener to be added. |
addAudioOffloadListener
public void addAudioOffloadListener(ExoPlayer.AudioOffloadListener listener)
Adds a listener to receive audio offload events.
This method can be called from any thread.
| Parameters | |
|---|---|
ExoPlayer.AudioOffloadListener listener |
The listener to register. |
addMediaSource
public void addMediaSource(MediaSource mediaSource)
Adds a media source to the end of the playlist.
| Parameters | |
|---|---|
MediaSource mediaSource |
The |
addMediaSource
public void addMediaSource(int index, MediaSource mediaSource)
Adds a media source at the given index of the playlist.
| Parameters | |
|---|---|
int index |
The index at which to add the source. |
MediaSource mediaSource |
The |
addMediaSources
public void addMediaSources(List<MediaSource> mediaSources)
Adds a list of media sources to the end of the playlist.
| Parameters | |
|---|---|
List<MediaSource> mediaSources |
The |
addMediaSources
public void addMediaSources(int index, List<MediaSource> mediaSources)
Adds a list of media sources at the given index of the playlist.
| Parameters | |
|---|---|
int index |
The index at which to add the media sources. |
List<MediaSource> mediaSources |
The |
clearAuxEffectInfo
public void clearAuxEffectInfo()
Detaches any previously attached auxiliary audio effect from the underlying audio track.
clearCameraMotionListener
public void clearCameraMotionListener(CameraMotionListener listener)
Clears the listener which receives camera motion events if it matches the one passed. Else does nothing.
| Parameters | |
|---|---|
CameraMotionListener listener |
The listener to clear. |
clearVideoFrameMetadataListener
public void clearVideoFrameMetadataListener(VideoFrameMetadataListener listener)
Clears the listener which receives video frame metadata events if it matches the one passed. Else does nothing.
| Parameters | |
|---|---|
VideoFrameMetadataListener listener |
The listener to clear. |
createMessage
public PlayerMessage createMessage(PlayerMessage.Target target)
Creates a message that can be sent to a PlayerMessage.Target. By default, the message will be delivered immediately without blocking on the playback thread. The default getType is 0 and the default getPayload is null. If a position is specified with setPosition, the message will be delivered at this position in the current media item defined by getCurrentMediaItemIndex. Alternatively, the message can be sent at a specific mediaItem using setPosition.
getAnalyticsCollector
public AnalyticsCollector getAnalyticsCollector()
Returns the AnalyticsCollector used for collecting analytics events.
getAudioDecoderCounters
public @Nullable DecoderCounters getAudioDecoderCounters()
Returns DecoderCounters for audio, or null if no audio is being played.
getAudioFormat
public @Nullable Format getAudioFormat()
Returns the audio format currently being played, or null if no audio is being played.
getAudioSessionId
public int getAudioSessionId()
Returns the audio session identifier, or AUDIO_SESSION_ID_UNSET if not set.
| See also | |
|---|---|
onAudioSessionIdChanged |
getClock
public Clock getClock()
Returns the Clock used for playback.
This method can be called from any thread.
getPauseAtEndOfMediaItems
public boolean getPauseAtEndOfMediaItems()
Returns whether the player pauses playback at the end of each media item.
| See also | |
|---|---|
setPauseAtEndOfMediaItems |
getPlaybackLooper
public Looper getPlaybackLooper()
Returns the Looper associated with the playback thread.
This method may be called from any thread.
getPlayerError
public ExoPlaybackException getPlayerError()
Returns the error that caused playback to fail. This is the same error that will have been reported via onPlayerError 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 getPlaybackState is not STATE_IDLE.
| Returns | |
|---|---|
ExoPlaybackException |
The error, or |
| See also | |
|---|---|
onPlayerError |
getPreloadConfiguration
public ExoPlayer.PreloadConfiguration getPreloadConfiguration()
Returns the preload configuration.
getRenderer
public Renderer getRenderer(int index)
Returns the renderer at the given index.
| Parameters | |
|---|---|
int index |
The index of the renderer. |
| Returns | |
|---|---|
Renderer |
The renderer at this index. |
getRendererType
public int getRendererType(int index)
Returns the track type that the renderer at a given index handles.
For example, a video renderer will return TRACK_TYPE_VIDEO, an audio renderer will return TRACK_TYPE_AUDIO and a text renderer will return TRACK_TYPE_TEXT.
| Parameters | |
|---|---|
int index |
The index of the renderer. |
| Returns | |
|---|---|
int |
The |
getScrubbingModeParameters
public ScrubbingModeParameters getScrubbingModeParameters()
Gets the parameters that control behavior in scrubbing mode.
getSecondaryRenderer
public Renderer getSecondaryRenderer(int index)
Returns the secondary renderer at the given index.
| Parameters | |
|---|---|
int index |
The index of the secondary renderer. |
| Returns | |
|---|---|
Renderer |
The secondary renderer at this index, or null if there is no secondary renderer at this index. |
getSeekParameters
public SeekParameters getSeekParameters()
Returns the currently active SeekParameters of the player.
getShuffleOrder
public ShuffleOrder getShuffleOrder()
Returns the shuffle order.
The ShuffleOrder returned will have the same length as the current playlist (getMediaItemCount).
getSkipSilenceEnabled
public boolean getSkipSilenceEnabled()
Returns whether skipping silences in the audio stream is enabled.
| See also | |
|---|---|
onSkipSilenceEnabledChanged |
getTrackSelector
public @Nullable TrackSelector getTrackSelector()
Returns the track selector that this player uses, or null if track selection is not supported.
getVideoChangeFrameRateStrategy
public int getVideoChangeFrameRateStrategy()
Returns the C.VideoChangeFrameRateStrategy.
getVideoDecoderCounters
public @Nullable DecoderCounters getVideoDecoderCounters()
Returns DecoderCounters for video, or null if no video is being played.
getVideoFormat
public @Nullable Format getVideoFormat()
Returns the video format currently being played, or null if no video is being played.
isReleased
public boolean isReleased()
Returns whether release has been called on the player.
This method is allowed to be called after release.
isScrubbingModeEnabled
public boolean isScrubbingModeEnabled()
Returns whether the player is optimized for scrubbing (many frequent seeks).
isSleepingForOffload
public boolean isSleepingForOffload()
Returns whether the player has paused its main loop to save power in offload scheduling mode.
Offload scheduling mode should save significant power when the phone is playing offload audio with the screen off.
Offload scheduling is only enabled when playing an audio track in offload mode, which requires all the following:
- Audio offload rendering is enabled through
setAudioOffloadPreferences. - An audio track is playing in a format that the device supports offloading (for example, MP3 or AAC).
- The
AudioSinkis playing with an offloadAudioTrack.
| See also | |
|---|---|
onSleepingForOffloadChanged |
isTunnelingEnabled
public boolean isTunnelingEnabled()
Returns whether tunneling is enabled for the currently selected tracks.
| See also | |
|---|---|
onTracksChanged |
removeAnalyticsListener
public void removeAnalyticsListener(AnalyticsListener listener)
Removes an AnalyticsListener.
| Parameters | |
|---|---|
AnalyticsListener listener |
The listener to be removed. |
removeAudioOffloadListener
public void removeAudioOffloadListener(ExoPlayer.AudioOffloadListener listener)
Removes a listener of audio offload events.
| Parameters | |
|---|---|
ExoPlayer.AudioOffloadListener listener |
The listener to unregister. |
setAudioAttributes
public void setAudioAttributes(
AudioAttributes audioAttributes,
boolean handleAudioFocus
)
Sets the attributes for audio playback, used by the underlying audio track. If not set, the default audio attributes will be used. They are suitable for general media playback.
Setting 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 audio focus should be handled, the usage must be USAGE_MEDIA or USAGE_GAME. Other usages will throw an IllegalArgumentException.
This method must only be called if COMMAND_SET_AUDIO_ATTRIBUTES is available.
| Parameters | |
|---|---|
AudioAttributes audioAttributes |
The attributes to use for audio playback. |
boolean handleAudioFocus |
True if the player should handle audio focus, false otherwise. |
setAudioSessionId
public void setAudioSessionId(int audioSessionId)
Sets the ID of the audio session to attach to the underlying android.media.AudioTrack.
The audio session ID can be generated using generateAudioSessionIdV21.
| Parameters | |
|---|---|
int audioSessionId |
The audio session ID, or |
setAuxEffectInfo
public void setAuxEffectInfo(AuxEffectInfo auxEffectInfo)
Sets information on an auxiliary audio effect to attach to the underlying audio track.
setCameraMotionListener
public void setCameraMotionListener(CameraMotionListener listener)
Sets a listener of camera motion events.
| Parameters | |
|---|---|
CameraMotionListener listener |
The listener. |
setForegroundMode
public 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. By doing so, the player may be able to reduce latency when starting to play another piece of content for which the same resources are required.
This 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:
- The application that owns the player is in the foreground.
- The player is used in a way that may benefit from foreground mode. For this to be true, the same player instance must be used to play multiple pieces of content, and there must be gaps between the playbacks (i.e.
stopis called to halt one playback, and prepare 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 stop does not need to be called, and simply calling prepare 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.
| Parameters | |
|---|---|
boolean foregroundMode |
Whether the player is allowed to keep limited resources even when in the idle state. |
setHandleAudioBecomingNoisy
public void setHandleAudioBecomingNoisy(boolean handleAudioBecomingNoisy)
Sets whether the player should pause automatically when audio is rerouted from a headset to device speakers. See the audio becoming noisy documentation for more information.
| Parameters | |
|---|---|
boolean handleAudioBecomingNoisy |
Whether the player should pause automatically when audio is rerouted from a headset to device speakers. |
setImageOutput
public void setImageOutput(@Nullable ImageOutput imageOutput)
Sets the ImageOutput where rendered images will be forwarded.
| Parameters | |
|---|---|
@Nullable ImageOutput imageOutput |
The |
setMaxSeekToPreviousPositionMs
public void setMaxSeekToPreviousPositionMs(long maxSeekToPreviousPositionMs)
Sets the maximum position for which seekToPrevious seeks to the previous MediaItem.
| Parameters | |
|---|---|
long maxSeekToPreviousPositionMs |
The maximum position, in milliseconds. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
setMediaSource
public void setMediaSource(MediaSource mediaSource)
Clears the playlist, adds the specified MediaSource and resets the position to the default position.
| Parameters | |
|---|---|
MediaSource mediaSource |
The new |
setMediaSource
public void setMediaSource(MediaSource mediaSource, boolean resetPosition)
Clears the playlist and adds the specified MediaSource.
| Parameters | |
|---|---|
MediaSource mediaSource |
The new |
boolean resetPosition |
Whether the playback position should be reset to the default position. If false, playback will start from the position defined by |
setMediaSource
public void setMediaSource(MediaSource mediaSource, long startPositionMs)
Clears the playlist and adds the specified MediaSource.
| Parameters | |
|---|---|
MediaSource mediaSource |
The new |
long startPositionMs |
The position in milliseconds to start playback from. If |
setMediaSources
public void setMediaSources(List<MediaSource> mediaSources)
Clears the playlist, adds the specified MediaSources and resets the position to the default position.
| Parameters | |
|---|---|
List<MediaSource> mediaSources |
The new |
setMediaSources
public void setMediaSources(List<MediaSource> mediaSources, boolean resetPosition)
Clears the playlist and adds the specified MediaSources.
| Parameters | |
|---|---|
List<MediaSource> mediaSources |
The new |
boolean resetPosition |
Whether the playback position should be reset to the default position in the first |
setMediaSources
public void setMediaSources(
List<MediaSource> mediaSources,
int startMediaItemIndex,
long startPositionMs
)
Clears the playlist and adds the specified MediaSources.
| Parameters | |
|---|---|
List<MediaSource> mediaSources |
The new |
int startMediaItemIndex |
The media item index to start playback from. If |
long startPositionMs |
The position in milliseconds to start playback from. If |
setPauseAtEndOfMediaItems
public void setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems)
Sets whether to pause playback at the end of each media item.
This means the player will pause at the end of each window in the current timeline. Listeners will be informed by a call to onPlayWhenReadyChanged with the reason PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM when this happens.
| Parameters | |
|---|---|
boolean pauseAtEndOfMediaItems |
Whether to pause playback at the end of each media item. |
setPreferredAudioDevice
public void setPreferredAudioDevice(@Nullable AudioDeviceInfo audioDeviceInfo)
Sets the preferred audio device.
| Parameters | |
|---|---|
@Nullable AudioDeviceInfo audioDeviceInfo |
The preferred |
setPreloadConfiguration
public void setPreloadConfiguration(
ExoPlayer.PreloadConfiguration preloadConfiguration
)
Sets the preload configuration to configure playlist preloading.
| Parameters | |
|---|---|
ExoPlayer.PreloadConfiguration preloadConfiguration |
The preload configuration. |
setPriority
public void setPriority(@C.Priority int priority)
Sets the C.Priority for this player.
The priority may influence resource allocation between multiple players or other components running in the same app.
This priority is used for the PriorityTaskManager, if set.
| Parameters | |
|---|---|
@C.Priority int priority |
The |
setPriorityTaskManager
public void setPriorityTaskManager(
@Nullable PriorityTaskManager priorityTaskManager
)
Sets a PriorityTaskManager, or null to clear a previously set priority task manager.
The priority set via setPriority (or by default) will be set while the player is loading.
| Parameters | |
|---|---|
@Nullable PriorityTaskManager priorityTaskManager |
The |
setScrubbingModeEnabled
public void setScrubbingModeEnabled(boolean scrubbingModeEnabled)
Sets whether to optimize the player for scrubbing (many frequent seeks).
The player may consume more resources in this mode, so it should only be used for short periods of time in response to user interaction (e.g. dragging on a progress bar UI element).
During scrubbing mode playback is suppressed with PLAYBACK_SUPPRESSION_REASON_SCRUBBING.
| Parameters | |
|---|---|
boolean scrubbingModeEnabled |
Whether scrubbing mode should be enabled. |
setScrubbingModeParameters
public void setScrubbingModeParameters(
ScrubbingModeParameters scrubbingModeParameters
)
Sets the parameters that control behavior in scrubbing mode.
setSeekBackIncrementMs
public void setSeekBackIncrementMs(long seekBackIncrementMs)
Sets the seekBack increment.
| Parameters | |
|---|---|
long seekBackIncrementMs |
The seek back increment, in milliseconds. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
setSeekForwardIncrementMs
public void setSeekForwardIncrementMs(long seekForwardIncrementMs)
Sets the seekForward increment.
| Parameters | |
|---|---|
long seekForwardIncrementMs |
The seek forward increment, in milliseconds. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
setSeekParameters
public void setSeekParameters(@Nullable SeekParameters seekParameters)
Sets the parameters that control how seek operations are performed.
| Parameters | |
|---|---|
@Nullable SeekParameters seekParameters |
The seek parameters, or |
setShuffleOrder
public void setShuffleOrder(ShuffleOrder shuffleOrder)
Sets the shuffle order.
The ShuffleOrder passed must have the same length as the current playlist (getMediaItemCount).
| Parameters | |
|---|---|
ShuffleOrder shuffleOrder |
The shuffle order. |
setSkipSilenceEnabled
public void setSkipSilenceEnabled(boolean skipSilenceEnabled)
Sets whether skipping silences in the audio stream is enabled.
| Parameters | |
|---|---|
boolean skipSilenceEnabled |
Whether skipping silences in the audio stream is enabled. |
setVideoChangeFrameRateStrategy
public void setVideoChangeFrameRateStrategy(int videoChangeFrameRateStrategy)
Sets a C.VideoChangeFrameRateStrategy that will be used by the player when provided with a video output Surface.
The strategy only applies if a MediaCodec-based video Renderer is enabled. Applications wishing to use CHANGE_FRAME_RATE_ALWAYS should set the mode to VIDEO_CHANGE_FRAME_RATE_STRATEGY_OFF to disable calls to setFrameRate from ExoPlayer, and should then call setFrameRate directly from application code.
| Parameters | |
|---|---|
int videoChangeFrameRateStrategy |
setVideoEffects
public void setVideoEffects(List<Effect> videoEffects)
Sets a List of video effects that will be applied to each video frame.
If passing a surface to the player directly, the output resolution needs to be signaled by passing a message to the video renderer with type MSG_SET_VIDEO_OUTPUT_RESOLUTION after calling this method. For SurfaceView, TextureView and SurfaceHolder output this happens automatically.
Pass REDRAW to force the effect pipeline to redraw the effects immediately. To accurately interleave redraws, listen to onVideoFrameAboutToBeRendered events.
The following limitations exist for using video effects:
- The
androidx.media3:media3-effectmodule must be available on the runtime classpath.androidx.media3:media3-exoplayerdoes not explicitly depend on the effect module, so apps must make sure it's available themselves. It must be the same version as the rest of theandroidx.media3modules being used by the app. - This feature works only with the default
MediaCodecVideoRendererand not custom or extensionvideo renderers. - This feature does not work with
effectsthat update the frame timestamps. - This feature does not work with DRM-protected content.
- This method must be called at least once before calling
prepare(in order to set up the effects pipeline). The effects can be changed during playback by subsequent calls to this method afterprepare.
| Parameters | |
|---|---|
List<Effect> videoEffects |
The |
setVideoFrameMetadataListener
public void setVideoFrameMetadataListener(VideoFrameMetadataListener listener)
Sets a listener to receive video frame metadata events.
This 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.
| Parameters | |
|---|---|
VideoFrameMetadataListener listener |
The listener. |
setVideoScalingMode
public void setVideoScalingMode(int videoScalingMode)
Sets the C.VideoScalingMode.
The scaling mode only applies if a MediaCodec-based video Renderer is enabled and if the output surface is owned by a SurfaceView.
| Parameters | |
|---|---|
int videoScalingMode |
The |
setVirtualDeviceId
public void setVirtualDeviceId(int virtualDeviceId)
Sets the virtual device id to be used for playback.
Note that the initial value is obtained from getDeviceId from the Context passed to Builder.
| Parameters | |
|---|---|
int virtualDeviceId |
The |
setWakeMode
public void setWakeMode(int wakeMode)
Sets how the player should keep the device awake for playback when the screen is off.
Enabling this feature requires the WAKE_LOCK permission. It should be used together with a foreground android.app.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 (android.os.PowerManager.WakeLock / android.net.wifi.WifiManager.WifiLock) will be held whenever the player is in the STATE_READY or STATE_BUFFERING states with playWhenReady = true. The locks held depends on the specified C.WakeMode.
| Parameters | |
|---|---|
int wakeMode |
The |