Add Audio Effects Feature on your Music App very easy and quick.
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
implementation 'com.github.xeinebiu:android_audioeffects:1.4.2'
}
1.4.1 .. 1.4.2
- Fix material dependency version
1.4.0
- Update dependencies
1.3.0
- Add Listeners when AudioEffectManager is Released
1.2.0
- Implement custom Listeners
1.1.2
- Fix wrong pointing listeners
1.1.1
- Clear all listeners when Release
1.1.0
- Add listeners for Equalizer & Bass Boost
1.0.1
- Improve: AudioEffectManager - Initial flag property
- Fix: Equalizer - Remember Current Preset
- Fix: EqualizerView - Bands level shown incorrectly
- Fix: BassView - Remember state
1.0.0
- Initial Releaes
You can read the Session Id of your Audio from the MediaPlayer
val audioSessionId = this.mediaPlayer.audioSessionId
After we have the audioSessionId
, we create AudioEffectManager
Here you will find equalizer
and bass boost
.
val audioEffectManager = AudioEffectManager(audioSessionId)
To help you more, on this library, we have created simple UI to work with the AudioEffectManager
A view to work only with the Equalizer
val view = EqualizerView(requireContext(), parent, audioEffectManager).createView()
parent.addView(view)
A view to work only with Bass Boost
val view = BassView(requireContext(), parent, audioEffectManager).createView()
parent.addView(view)
A helper to create views for us as Dialog, Bottom Sheet or Child View.
It creates a Tabbed Layout with the equalizer
and bass
view's.
val audioEffectViewHelper = AudioEffectViewHelper(
this,
supportFragmentManager,
audioEffectManager
)
// show the tabbed layout as dialog
audioEffectViewHelper.showAsDialog()
audioEffectViewHelper.showAsBottomSheet()
// add the tabbed layout on specific container
val audioEffectView = audioEffectViewHelper.asView(container)
container.addView(audioEffectView)
Releasing the AudioEffectManager must be done when not needed.
override fun onDestroy() {
super.onDestroy()
mediaPlayer.stop()
mediaPlayer.release()
audioEffectManager.release()
}
xeinebiu