Interface ExoPlayerSettings
-
Method Summary
Modifier and TypeMethodDescriptionvoiddefault AudioFocusListenerReturns the listener set withsetAudioFocusListener(AudioFocusListener).androidx.media3.exoplayer.LoadControldefault booleanReturns whether the player manages audio focus.booleanbooleanReturns whether CMCD logging is enabled.booleanReturns whether locale-based default track selection is enabled.default voidsetAudioFocusHandlingEnabled(boolean enabled) Enables or disables audio-focus handling by the player.default voidsetAudioFocusListener(AudioFocusListener listener) Sets a listener for audio-focus changes, ornullto remove it.voidsetCmcdEnabled(boolean enabled) Enables or disables Common Media Client Data (CMCD) logging.voidsetLoadControl(androidx.media3.exoplayer.LoadControl loadControl) voidsetLocaleBasedTrackSelectionEnabled(boolean enabled) Enables or disables locale-based default track selection.
-
Method Details
-
setLoadControl
void setLoadControl(@Nullable androidx.media3.exoplayer.LoadControl loadControl) -
getLoadControl
@NonNull androidx.media3.exoplayer.LoadControl getLoadControl() -
enableChunkLessPreparation
void enableChunkLessPreparation() -
isChunkLessPreparationEnabled
boolean isChunkLessPreparationEnabled() -
setCmcdEnabled
void setCmcdEnabled(boolean enabled) Enables or disables Common Media Client Data (CMCD) logging.When enabled, standardized client metadata is sent in HTTP request headers to CDNs, allowing them to optimize delivery. CMCD is defined by the CTA-5004 specification.
Disabled by default.
- Parameters:
enabled-trueto enable CMCD,falseto disable.
-
isCmcdEnabled
boolean isCmcdEnabled()Returns whether CMCD logging is enabled.- Returns:
trueif CMCD is enabled,falseotherwise.
-
setLocaleBasedTrackSelectionEnabled
void setLocaleBasedTrackSelectionEnabled(boolean enabled) Enables or disables locale-based default track selection.When enabled, the player applies the device locale as the preferred audio and text language, sizes the viewport to the physical display, and auto-selects a text track when the OS accessibility captioning service is on. When disabled, the player uses ExoPlayer's default track-selection parameters and honors the stream's own default tracks.
Disabled by default to preserve the historical default-track behavior.
- Parameters:
enabled-trueto enable locale-based track selection,falseto disable.
-
isLocaleBasedTrackSelectionEnabled
boolean isLocaleBasedTrackSelectionEnabled()Returns whether locale-based default track selection is enabled.- Returns:
trueif locale-based track selection is enabled,falseotherwise.
-
setAudioFocusHandlingEnabled
default void setAudioFocusHandlingEnabled(boolean enabled) Enables or disables audio-focus handling by the player.Disabled by default. When enabled, the player requests audio focus (
AUDIOFOCUS_GAIN, media usage) when content or an ad starts playing and releases it when playback is paused, completes, errors, is stopped, starts casting or the player is destroyed. When another app takes focus:- permanent loss (another media app plays): the player pauses and stays paused;
- transient loss (assistant prompt, call): the player pauses and resumes when focus returns, unless the user or the app paused or played in between, or the app is in the background without background audio;
- "duck" requests (notifications, navigation prompts): on Android 8.0+ the system
lowers the volume itself and the player is not told, so it keeps playing and
AudioFocusChange.DUCKis never reported. Only below Android 8.0 does the player receive the duck request; it then pauses and resumes as for a transient loss.
Each player handles focus independently. With two players on screen that both have this enabled, starting one takes focus from the other, which pauses: they pause each other. Every pause the player makes for audio focus is reported as a pause with
PauseReason.AUDIO_INTERRUPTION.Leave this off if your app manages audio focus itself (for example with
AudioManager.requestAudioFocusand callingJWPlayer.pause()/JWPlayer.play()from its own focus listener). Do not enable it as well as handling focus yourself: both would react to the same change.Independent of this setting, the player always pauses when headphones or a Bluetooth audio device disconnect (
ACTION_AUDIO_BECOMING_NOISY).Can be changed at any time: enabling while playing requests focus immediately, disabling releases it.
- Parameters:
enabled-trueto let the player manage audio focus,false(default) to leave audio focus to the app.
-
isAudioFocusHandlingEnabled
default boolean isAudioFocusHandlingEnabled()Returns whether the player manages audio focus.- Returns:
trueif audio-focus handling is enabled,false(default) otherwise.- See Also:
-
setAudioFocusListener
Sets a listener for audio-focus changes, ornullto remove it.Always called on the main thread, and only while
setAudioFocusHandlingEnabled(boolean)is enabled.- Parameters:
listener- the listener, ornull
-
getAudioFocusListener
Returns the listener set withsetAudioFocusListener(AudioFocusListener).- Returns:
- the listener, or
nullif none is set
-