StubExoPlayer
@UnstableApi
class StubExoPlayer : StubPlayer, ExoPlayer
| kotlin.Any | |||
| ↳ | 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 functions |
|
|---|---|
Unit |
addAnalyticsListener(listener: AnalyticsListener!)Adds an |
Unit |
addAudioCodecParametersChangeListener(Adds a listener for audio codec parameter changes. |
Unit |
Adds a listener to receive audio offload events. |
Unit |
addMediaSource(mediaSource: MediaSource!)Adds a media source to the end of the playlist. |
Unit |
addMediaSource(index: Int, mediaSource: MediaSource!)Adds a media source at the given index of the playlist. |
Unit |
addMediaSources(mediaSources: (Mutable)List<MediaSource!>!)Adds a list of media sources to the end of the playlist. |
Unit |
addMediaSources(index: Int, mediaSources: (Mutable)List<MediaSource!>!)Adds a list of media sources at the given index of the playlist. |
Unit |
addVideoCodecParametersChangeListener(Adds a listener for video codec parameter changes. |
Unit |
Detaches any previously attached auxiliary audio effect from the underlying audio track. |
Unit |
clearCameraMotionListener(listener: CameraMotionListener!)Clears the listener which receives camera motion events if it matches the one passed. |
Unit |
Clears the listener which receives video frame metadata events if it matches the one passed. |
PlayerMessage! |
createMessage(target: PlayerMessage.Target!)Creates a message that can be sent to a |
AnalyticsCollector! |
Returns the |
DecoderCounters? |
Returns |
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 function is deprecated. Use |
TrackSelectionArray! |
This function 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(index: Int)Returns the renderer at the given index. |
Int |
Returns the number of renderers. |
Int |
getRendererType(index: Int)Returns the track type that the renderer at a given index handles. |
ScrubbingModeParameters! |
Gets the parameters that control behavior in |
Renderer! |
getSecondaryRenderer(index: Int)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. |
TrackSelector? |
Returns the track selector that this player uses, or null if track selection is not supported. |
Int |
Returns the |
DecoderCounters? |
Returns |
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. |
Unit |
This function is deprecated. Use |
Unit |
This function is deprecated. Use |
Unit |
removeAnalyticsListener(listener: AnalyticsListener!)Removes an |
Unit |
Removes a listener for audio codec parameter changes. |
Unit |
Removes a listener of audio offload events. |
Unit |
Removes a listener for video codec parameter changes. |
Unit |
setAudioAttributes(Sets the attributes for audio playback, used by the underlying audio track. |
Unit |
setAudioCodecParameters(codecParameters: CodecParameters!)Sets a collection of parameters on the underlying audio codecs. |
Unit |
setAudioSessionId(audioSessionId: Int)Sets the ID of the audio session to attach to the underlying |
Unit |
setAuxEffectInfo(auxEffectInfo: AuxEffectInfo!)Sets information on an auxiliary audio effect to attach to the underlying audio track. |
Unit |
setCameraMotionListener(listener: CameraMotionListener!)Sets a listener of camera motion events. |
Unit |
setForegroundMode(foregroundMode: Boolean)Sets whether the player is allowed to keep holding limited resources such as video decoders, even when in the idle state. |
Unit |
setHandleAudioBecomingNoisy(handleAudioBecomingNoisy: Boolean)Sets whether the player should pause automatically when audio is rerouted from a headset to device speakers. |
Unit |
setImageOutput(imageOutput: ImageOutput?)Sets the |
Unit |
setMaxSeekToPreviousPositionMs(maxSeekToPreviousPositionMs: Long)Sets the maximum position for which |
Unit |
setMediaSource(mediaSource: MediaSource!)Clears the playlist, adds the specified |
Unit |
setMediaSource(mediaSource: MediaSource!, resetPosition: Boolean)Clears the playlist and adds the specified |
Unit |
setMediaSource(mediaSource: MediaSource!, startPositionMs: Long)Clears the playlist and adds the specified |
Unit |
setMediaSources(mediaSources: (Mutable)List<MediaSource!>!)Clears the playlist, adds the specified |
Unit |
setMediaSources(Clears the playlist and adds the specified |
Unit |
setMediaSources(Clears the playlist and adds the specified |
Unit |
setPauseAtEndOfMediaItems(pauseAtEndOfMediaItems: Boolean)Sets whether to pause playback at the end of each media item. |
Unit |
setPreferredAudioDevice(audioDeviceInfo: AudioDeviceInfo?)Sets the preferred audio device. |
Unit |
setPreloadConfiguration(Sets the |
Unit |
setPriority(@C.Priority priority: Int)Sets the |
Unit |
setPriorityTaskManager(priorityTaskManager: PriorityTaskManager?)Sets a |
Unit |
setScrubbingModeEnabled(scrubbingModeEnabled: Boolean)Sets whether to optimize the player for scrubbing (many frequent seeks). |
Unit |
setScrubbingModeParameters(Sets the parameters that control behavior in |
Unit |
setSeekBackIncrementMs(seekBackIncrementMs: Long)Sets the |
Unit |
setSeekForwardIncrementMs(seekForwardIncrementMs: Long)Sets the |
Unit |
setSeekParameters(seekParameters: SeekParameters?)Sets the parameters that control how seek operations are performed. |
Unit |
setShuffleOrder(shuffleOrder: ShuffleOrder!)Sets the shuffle order. |
Unit |
setSkipSilenceEnabled(skipSilenceEnabled: Boolean)Sets whether skipping silences in the audio stream is enabled. |
Unit |
setVideoChangeFrameRateStrategy(videoChangeFrameRateStrategy: Int)Sets a |
Unit |
setVideoCodecParameters(codecParameters: CodecParameters!)Sets a collection of parameters on the underlying video codecs. |
Unit |
setVideoEffects(videoEffects: (Mutable)List<Effect!>!)Sets a |
Unit |
Sets a listener to receive video frame metadata events. |
Unit |
setVideoScalingMode(videoScalingMode: Int)Sets the |
Unit |
setVirtualDeviceId(virtualDeviceId: Int)Sets the virtual device id to be used for playback. |
Unit |
setWakeMode(wakeMode: Int)Sets how the player should keep the device awake for playback when the screen is off. |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Inherited properties |
|---|
Public constructors
Public functions
addAnalyticsListener
fun addAnalyticsListener(listener: AnalyticsListener!): Unit
Adds an AnalyticsListener to receive analytics events.
This method can be called from any thread.
| Parameters | |
|---|---|
listener: AnalyticsListener! |
The listener to be added. |
addAudioCodecParametersChangeListener
fun addAudioCodecParametersChangeListener(
listener: CodecParametersChangeListener!,
keys: (Mutable)List<String!>!
): Unit
Adds a listener for audio codec parameter changes.
The listener will be called on the application thread. Upon registration, the listener will be immediately called with the last known values for the subscribed keys.
The default MediaCodec based renderers only support this feature on API level 29 and above.
Note: When used with MediaCodec, observing vendor-specific parameter changes requires API level 31 or higher. On API levels 29 and 30, any requested vendor-specific keys will be ignored.
| Parameters | |
|---|---|
listener: CodecParametersChangeListener! |
The |
keys: (Mutable)List<String!>! |
The list of parameter keys to subscribe to. |
addAudioOffloadListener
fun addAudioOffloadListener(listener: ExoPlayer.AudioOffloadListener!): Unit
Adds a listener to receive audio offload events.
This method can be called from any thread.
| Parameters | |
|---|---|
listener: ExoPlayer.AudioOffloadListener! |
The listener to register. |
addMediaSource
fun addMediaSource(mediaSource: MediaSource!): Unit
Adds a media source to the end of the playlist.
| Parameters | |
|---|---|
mediaSource: MediaSource! |
The |
addMediaSource
fun addMediaSource(index: Int, mediaSource: MediaSource!): Unit
Adds a media source at the given index of the playlist.
| Parameters | |
|---|---|
index: Int |
The index at which to add the source. |
mediaSource: MediaSource! |
The |
addMediaSources
fun addMediaSources(mediaSources: (Mutable)List<MediaSource!>!): Unit
Adds a list of media sources to the end of the playlist.
| Parameters | |
|---|---|
mediaSources: (Mutable)List<MediaSource!>! |
The |
addMediaSources
fun addMediaSources(index: Int, mediaSources: (Mutable)List<MediaSource!>!): Unit
Adds a list of media sources at the given index of the playlist.
| Parameters | |
|---|---|
index: Int |
The index at which to add the media sources. |
mediaSources: (Mutable)List<MediaSource!>! |
The |
addVideoCodecParametersChangeListener
fun addVideoCodecParametersChangeListener(
listener: CodecParametersChangeListener!,
keys: (Mutable)List<String!>!
): Unit
Adds a listener for video codec parameter changes.
The listener will be called on the application thread. Upon registration, the listener will be immediately called with the last known values for the subscribed keys.
The default MediaCodec based renderers only support this feature on API level 29 and above.
Note: When used with MediaCodec, observing vendor-specific parameter changes requires API level 31 or higher. On API levels 29 and 30, any requested vendor-specific keys will be ignored.
| Parameters | |
|---|---|
listener: CodecParametersChangeListener! |
The |
keys: (Mutable)List<String!>! |
The list of parameter keys to subscribe to. |
clearAuxEffectInfo
fun clearAuxEffectInfo(): Unit
Detaches any previously attached auxiliary audio effect from the underlying audio track.
clearCameraMotionListener
fun clearCameraMotionListener(listener: CameraMotionListener!): Unit
Clears the listener which receives camera motion events if it matches the one passed. Else does nothing.
| Parameters | |
|---|---|
listener: CameraMotionListener! |
The listener to clear. |
clearVideoFrameMetadataListener
fun clearVideoFrameMetadataListener(listener: VideoFrameMetadataListener!): Unit
Clears the listener which receives video frame metadata events if it matches the one passed. Else does nothing.
| Parameters | |
|---|---|
listener: VideoFrameMetadataListener! |
The listener to clear. |
createMessage
fun createMessage(target: PlayerMessage.Target!): PlayerMessage!
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
fun getAnalyticsCollector(): AnalyticsCollector!
Returns the AnalyticsCollector used for collecting analytics events.
getAudioDecoderCounters
fun getAudioDecoderCounters(): DecoderCounters?
Returns DecoderCounters for audio, or null if no audio is being played.
getAudioFormat
fun getAudioFormat(): Format?
Returns the audio format currently being played, or null if no audio is being played.
getAudioSessionId
fun getAudioSessionId(): Int
Returns the audio session identifier, or AUDIO_SESSION_ID_UNSET if not set.
| See also | |
|---|---|
onAudioSessionIdChanged |
getClock
fun getClock(): Clock!
Returns the Clock used for playback.
This method can be called from any thread.
getPauseAtEndOfMediaItems
fun getPauseAtEndOfMediaItems(): Boolean
Returns whether the player pauses playback at the end of each media item.
| See also | |
|---|---|
setPauseAtEndOfMediaItems |
getPlaybackLooper
fun getPlaybackLooper(): Looper!
Returns the Looper associated with the playback thread.
This method may be called from any thread.
getPlayerError
fun getPlayerError(): ExoPlaybackException!
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
fun getPreloadConfiguration(): ExoPlayer.PreloadConfiguration!
Returns the preload configuration.
getRenderer
fun getRenderer(index: Int): Renderer!
Returns the renderer at the given index.
| Parameters | |
|---|---|
index: Int |
The index of the renderer. |
| Returns | |
|---|---|
Renderer! |
The renderer at this index. |
getRendererType
fun getRendererType(index: Int): Int
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 | |
|---|---|
index: Int |
The index of the renderer. |
| Returns | |
|---|---|
Int |
The |
getScrubbingModeParameters
fun getScrubbingModeParameters(): ScrubbingModeParameters!
Gets the parameters that control behavior in scrubbing mode.
getSecondaryRenderer
fun getSecondaryRenderer(index: Int): Renderer!
Returns the secondary renderer at the given index.
| Parameters | |
|---|---|
index: Int |
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
fun getSeekParameters(): SeekParameters!
Returns the currently active SeekParameters of the player.
getShuffleOrder
fun getShuffleOrder(): ShuffleOrder!
Returns the shuffle order.
The ShuffleOrder returned will have the same length as the current playlist (getMediaItemCount).
getSkipSilenceEnabled
fun getSkipSilenceEnabled(): Boolean
Returns whether skipping silences in the audio stream is enabled.
| See also | |
|---|---|
onSkipSilenceEnabledChanged |
getTrackSelector
fun getTrackSelector(): TrackSelector?
Returns the track selector that this player uses, or null if track selection is not supported.
getVideoChangeFrameRateStrategy
fun getVideoChangeFrameRateStrategy(): Int
Returns the C.VideoChangeFrameRateStrategy.
getVideoDecoderCounters
fun getVideoDecoderCounters(): DecoderCounters?
Returns DecoderCounters for video, or null if no video is being played.
getVideoFormat
fun getVideoFormat(): Format?
Returns the video format currently being played, or null if no video is being played.
isReleased
fun isReleased(): Boolean
Returns whether release has been called on the player.
This method is allowed to be called after release.
isScrubbingModeEnabled
fun isScrubbingModeEnabled(): Boolean
Returns whether the player is optimized for scrubbing (many frequent seeks).
isSleepingForOffload
fun isSleepingForOffload(): Boolean
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
fun isTunnelingEnabled(): Boolean
Returns whether tunneling is enabled for the currently selected tracks.
| See also | |
|---|---|
onTracksChanged |
removeAnalyticsListener
fun removeAnalyticsListener(listener: AnalyticsListener!): Unit
Removes an AnalyticsListener.
| Parameters | |
|---|---|
listener: AnalyticsListener! |
The listener to be removed. |
removeAudioCodecParametersChangeListener
fun removeAudioCodecParametersChangeListener(
listener: CodecParametersChangeListener!
): Unit
Removes a listener for audio codec parameter changes.
| Parameters | |
|---|---|
listener: CodecParametersChangeListener! |
The |
removeAudioOffloadListener
fun removeAudioOffloadListener(listener: ExoPlayer.AudioOffloadListener!): Unit
Removes a listener of audio offload events.
| Parameters | |
|---|---|
listener: ExoPlayer.AudioOffloadListener! |
The listener to unregister. |
removeVideoCodecParametersChangeListener
fun removeVideoCodecParametersChangeListener(
listener: CodecParametersChangeListener!
): Unit
Removes a listener for video codec parameter changes.
| Parameters | |
|---|---|
listener: CodecParametersChangeListener! |
The |
setAudioAttributes
fun setAudioAttributes(
audioAttributes: AudioAttributes!,
handleAudioFocus: Boolean
): Unit
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. |
handleAudioFocus: Boolean |
True if the player should handle audio focus, false otherwise. |
setAudioCodecParameters
fun setAudioCodecParameters(codecParameters: CodecParameters!): Unit
Sets a collection of parameters on the underlying audio codecs.
This method is asynchronous. The parameters will be applied to the audio renderers on the playback thread.
The default MediaCodec based renderers only support this feature on API level 29 and above. If an underlying decoder does not support a parameter, it will be ignored.
| Parameters | |
|---|---|
codecParameters: CodecParameters! |
The |
setAudioSessionId
fun setAudioSessionId(audioSessionId: Int): Unit
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 | |
|---|---|
audioSessionId: Int |
The audio session ID, or |
setAuxEffectInfo
fun setAuxEffectInfo(auxEffectInfo: AuxEffectInfo!): Unit
Sets information on an auxiliary audio effect to attach to the underlying audio track.
setCameraMotionListener
fun setCameraMotionListener(listener: CameraMotionListener!): Unit
Sets a listener of camera motion events.
| Parameters | |
|---|---|
listener: CameraMotionListener! |
The listener. |
setForegroundMode
fun setForegroundMode(foregroundMode: Boolean): Unit
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 | |
|---|---|
foregroundMode: Boolean |
Whether the player is allowed to keep limited resources even when in the idle state. |
setHandleAudioBecomingNoisy
fun setHandleAudioBecomingNoisy(handleAudioBecomingNoisy: Boolean): Unit
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 | |
|---|---|
handleAudioBecomingNoisy: Boolean |
Whether the player should pause automatically when audio is rerouted from a headset to device speakers. |
setImageOutput
fun setImageOutput(imageOutput: ImageOutput?): Unit
Sets the ImageOutput where rendered images will be forwarded.
| Parameters | |
|---|---|
imageOutput: ImageOutput? |
The |
setMaxSeekToPreviousPositionMs
fun setMaxSeekToPreviousPositionMs(maxSeekToPreviousPositionMs: Long): Unit
Sets the maximum position for which seekToPrevious seeks to the previous MediaItem.
| Parameters | |
|---|---|
maxSeekToPreviousPositionMs: Long |
The maximum position, in milliseconds. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
setMediaSource
fun setMediaSource(mediaSource: MediaSource!): Unit
Clears the playlist, adds the specified MediaSource and resets the position to the default position.
| Parameters | |
|---|---|
mediaSource: MediaSource! |
The new |
setMediaSource
fun setMediaSource(mediaSource: MediaSource!, resetPosition: Boolean): Unit
Clears the playlist and adds the specified MediaSource.
| Parameters | |
|---|---|
mediaSource: MediaSource! |
The new |
resetPosition: Boolean |
Whether the playback position should be reset to the default position. If false, playback will start from the position defined by |
setMediaSource
fun setMediaSource(mediaSource: MediaSource!, startPositionMs: Long): Unit
Clears the playlist and adds the specified MediaSource.
| Parameters | |
|---|---|
mediaSource: MediaSource! |
The new |
startPositionMs: Long |
The position in milliseconds to start playback from. If |
setMediaSources
fun setMediaSources(mediaSources: (Mutable)List<MediaSource!>!): Unit
Clears the playlist, adds the specified MediaSources and resets the position to the default position.
| Parameters | |
|---|---|
mediaSources: (Mutable)List<MediaSource!>! |
The new |
setMediaSources
fun setMediaSources(
mediaSources: (Mutable)List<MediaSource!>!,
resetPosition: Boolean
): Unit
Clears the playlist and adds the specified MediaSources.
| Parameters | |
|---|---|
mediaSources: (Mutable)List<MediaSource!>! |
The new |
resetPosition: Boolean |
Whether the playback position should be reset to the default position in the first |
setMediaSources
fun setMediaSources(
mediaSources: (Mutable)List<MediaSource!>!,
startMediaItemIndex: Int,
startPositionMs: Long
): Unit
Clears the playlist and adds the specified MediaSources.
| Parameters | |
|---|---|
mediaSources: (Mutable)List<MediaSource!>! |
The new |
startMediaItemIndex: Int |
The media item index to start playback from. If |
startPositionMs: Long |
The position in milliseconds to start playback from. If |
setPauseAtEndOfMediaItems
fun setPauseAtEndOfMediaItems(pauseAtEndOfMediaItems: Boolean): Unit
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 | |
|---|---|
pauseAtEndOfMediaItems: Boolean |
Whether to pause playback at the end of each media item. |
setPreferredAudioDevice
fun setPreferredAudioDevice(audioDeviceInfo: AudioDeviceInfo?): Unit
Sets the preferred audio device.
| Parameters | |
|---|---|
audioDeviceInfo: AudioDeviceInfo? |
The preferred |
setPreloadConfiguration
fun setPreloadConfiguration(
preloadConfiguration: ExoPlayer.PreloadConfiguration!
): Unit
Sets the preload configuration to configure playlist preloading.
| Parameters | |
|---|---|
preloadConfiguration: ExoPlayer.PreloadConfiguration! |
The preload configuration. |
setPriority
fun setPriority(@C.Priority priority: Int): Unit
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 priority: Int |
The |
setPriorityTaskManager
fun setPriorityTaskManager(priorityTaskManager: PriorityTaskManager?): Unit
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 | |
|---|---|
priorityTaskManager: PriorityTaskManager? |
The |
setScrubbingModeEnabled
fun setScrubbingModeEnabled(scrubbingModeEnabled: Boolean): Unit
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 | |
|---|---|
scrubbingModeEnabled: Boolean |
Whether scrubbing mode should be enabled. |
setScrubbingModeParameters
fun setScrubbingModeParameters(
scrubbingModeParameters: ScrubbingModeParameters!
): Unit
Sets the parameters that control behavior in scrubbing mode.
setSeekBackIncrementMs
fun setSeekBackIncrementMs(seekBackIncrementMs: Long): Unit
Sets the seekBack increment.
| Parameters | |
|---|---|
seekBackIncrementMs: Long |
The seek back increment, in milliseconds. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
setSeekForwardIncrementMs
fun setSeekForwardIncrementMs(seekForwardIncrementMs: Long): Unit
Sets the seekForward increment.
| Parameters | |
|---|---|
seekForwardIncrementMs: Long |
The seek forward increment, in milliseconds. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
setSeekParameters
fun setSeekParameters(seekParameters: SeekParameters?): Unit
Sets the parameters that control how seek operations are performed.
| Parameters | |
|---|---|
seekParameters: SeekParameters? |
The seek parameters, or |
setShuffleOrder
fun setShuffleOrder(shuffleOrder: ShuffleOrder!): Unit
Sets the shuffle order.
The ShuffleOrder passed must have the same length as the current playlist (getMediaItemCount).
| Parameters | |
|---|---|
shuffleOrder: ShuffleOrder! |
The shuffle order. |
setSkipSilenceEnabled
fun setSkipSilenceEnabled(skipSilenceEnabled: Boolean): Unit
Sets whether skipping silences in the audio stream is enabled.
| Parameters | |
|---|---|
skipSilenceEnabled: Boolean |
Whether skipping silences in the audio stream is enabled. |
setVideoChangeFrameRateStrategy
fun setVideoChangeFrameRateStrategy(videoChangeFrameRateStrategy: Int): Unit
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 | |
|---|---|
videoChangeFrameRateStrategy: Int |
setVideoCodecParameters
fun setVideoCodecParameters(codecParameters: CodecParameters!): Unit
Sets a collection of parameters on the underlying video codecs.
This method is asynchronous. The parameters will be applied to the video renderers on the playback thread.
The default MediaCodec based renderers only support this feature on API level 29 and above. If an underlying decoder does not support a parameter, it will be ignored.
| Parameters | |
|---|---|
codecParameters: CodecParameters! |
The |
setVideoEffects
fun setVideoEffects(videoEffects: (Mutable)List<Effect!>!): Unit
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 | |
|---|---|
videoEffects: (Mutable)List<Effect!>! |
The |
setVideoFrameMetadataListener
fun setVideoFrameMetadataListener(listener: VideoFrameMetadataListener!): Unit
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 | |
|---|---|
listener: VideoFrameMetadataListener! |
The listener. |
setVideoScalingMode
fun setVideoScalingMode(videoScalingMode: Int): Unit
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 | |
|---|---|
videoScalingMode: Int |
The |
setVirtualDeviceId
fun setVirtualDeviceId(virtualDeviceId: Int): Unit
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 | |
|---|---|
virtualDeviceId: Int |
The |
setWakeMode
fun setWakeMode(wakeMode: Int): Unit
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 | |
|---|---|
wakeMode: Int |
The |