Interface ExoPlayerSettings


public interface ExoPlayerSettings
  • 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 - true to enable CMCD, false to disable.
    • isCmcdEnabled

      boolean isCmcdEnabled()
      Returns whether CMCD logging is enabled.
      Returns:
      true if CMCD is enabled, false otherwise.
    • 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 - true to enable locale-based track selection, false to disable.
    • isLocaleBasedTrackSelectionEnabled

      boolean isLocaleBasedTrackSelectionEnabled()
      Returns whether locale-based default track selection is enabled.
      Returns:
      true if locale-based track selection is enabled, false otherwise.
    • 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.DUCK is never reported. Only below Android 8.0 does the player receive the duck request; it then pauses and resumes as for a transient loss.
      Focus is not requested while the player is muted (it is requested when the player is unmuted while playing), nor while the host Activity is not in the foreground with window focus, unless background audio is allowed or the player is in picture-in-picture. Focus is not handled while casting: the audio plays on the receiver, so focus is released when a cast session starts.

      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.requestAudioFocus and calling JWPlayer.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 - true to 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:
      true if audio-focus handling is enabled, false (default) otherwise.
      See Also:
    • setAudioFocusListener

      default void setAudioFocusListener(@Nullable AudioFocusListener listener)
      Sets a listener for audio-focus changes, or null to remove it.

      Always called on the main thread, and only while setAudioFocusHandlingEnabled(boolean) is enabled.

      Parameters:
      listener - the listener, or null
    • getAudioFocusListener

      @Nullable default AudioFocusListener getAudioFocusListener()
      Returns the listener set with setAudioFocusListener(AudioFocusListener).
      Returns:
      the listener, or null if none is set