How to enable audio offload in Jetpack Compose Media3 Exoplayer in ver. 1.2

214 Views Asked by At

In version 1.1 (and backwards) there was an option to offload audio with .setEnableAudiOffload in Exoplayer.Builder.

In version 1.2 they removed it and they only mentioned this:

Offload can be enabled through setAudioOffloadPreference in TrackSelectionParameters. If the set preference is to enable, the device supports offload for the format, and the track selection is a single audio track, then audio offload will be enabled.

But how and where do we use TrackSelectionParameters? Remains unclear to me.

1

There are 1 best solutions below

0
On BEST ANSWER

Don't know if this is the right solution, but I found an API like this:

exoPlayer.trackSelectionParameters = exoPlayer.trackSelectionParameters
    .buildUpon()
    .setAudioOffloadPreferences(
         AudioOffloadPreferences
             .Builder()
             .setAudioOffloadMode(AudioOffloadPreferences.AUDIO_OFFLOAD_MODE_ENABLED)
             .build()
    )
    .build()