How can we add a reverb effect to exoplayer in android

Viewed 286

I have used the below code to add reverb effect to exoplayer. I Don't think the effect is being applied, Can anyone help me get the audio filters applied to the video/audio played

val reverb =  PresetReverb(1, 0)
reverb.preset = PresetReverb.PRESET_LARGEHALL
reverb.enabled = true
simplePlayer?.setAuxEffectInfo(AuxEffectInfo(reverb.id, 1.0f))
simplePlayer?.prepare(mediaSource, true, true)
simplePlayer?.repeatMode = Player.REPEAT_MODE_OFF
simplePlayer?.playWhenReady = true
1 Answers

You can add reverb effect by choosing the priority and audio session of the Audio Track. As you want to add the reverb effect to an exoplayer instance, you should use

simplePlayer.audioSessionId

This should be done each time, when there is change in the exoplayer playback(i.e. playing of new file, change of media Item)

For applying the reverb effect

val reverb = PresetReverb(1, simplePlayer.audioSessionId)

reverb.preset = PresetReverb.PRESET_LARGEHALL
reverb.enabled = true
simplePlayer.setAuxEffectInfo(AuxEffectInfo(reverb.id,1f))

For removing the reverb effect

reverb.enabled=false
simplePlayer.clearAuxEffectInfo()

For any further help refer to Preset Reverb

Related