Skip to content

[EN] 6.EqualizerActivity

jrfeng edited this page Jul 3, 2022 · 3 revisions

EqualizerActivity Preview:

EqualizerActivity Preview

Add dependency:

dependencies {
    implementation 'com.github.jrfeng.snow:ui:1.2'
}

The ui module provides an EqualizerActivity and an AndroidAudioEffectManager, which cooperate to implement audio effects. EqualizerActivity is used to provide users with a UI interface for editing audio effects, and AndroidAudioEffectManager is used to ensure that audio effects are still valid after exiting EqualizerActivity and switching songs.

The EqualizerActivity provides the following 3 kinds of Android audio effects:

Getting Start

Step 1. Register EqualizerActivity on your AndroidManifest.xml file:

<activity
    android:name="snow.player.ui.equalizer.EqualizerActivity"
    android:launchMode="singleTask"
    android:screenOrientation="portrait"
    android:theme="@style/EqualizerTheme" />

Step 2. Override the onCreateAudioEffectManager() of PlayerService and return an AndroidAudioEffectManager instance.

public class MyPlayerService extends PlayerService {
    ...
    @Nullable
    @Override
    protected AudioEffectManager onCreateAudioEffectManager() {
        return new AndroidAudioEffectManager();
    }
}

Start EqualizerActivity

You need use the static method EqualizerActivity.start(Context, Class<? extends PlayerService>) to start EqualizerActivity instead of using Context#startActivity().

Example:

EqualizerActivity.start(context, MyPlayerService.class);

End