Search code examples
javaandroidexoplayer

Exoplayer battery consumption for audio playback in media3-exoplayer:1.2.0


to reduce battery consumption ExoPlayer introduced support for audio offload in 2.12 as an experimental feature. This function is no longer available in the media3 library for the current Exoplayer version 1.2.0. I cannot find anything about this in the documentation. Is there another way to reduce the battery consumption for audio playback?

Thanks GGK


Solution

  • It's still there:
    https://developer.android.com/guide/topics/media/exoplayer/track-selection#audioOffload

    val audioOffloadPreferences =
      AudioOffloadPreferences.Builder()
          .setAudioOffloadMode(AudioOffloadPreferences.AUDIO_OFFLOAD_MODE_ENABLED)
          // Add additional options as needed
          .setIsGaplessSupportRequired(true)
          .build()
    player.trackSelectionParameters =
      player.trackSelectionParameters
        .buildUpon()
        .setAudioOffloadPreferences(audioOffloadPreferences)
        .build()