android - 将均衡器附加到 Android 全局音频输出

标签 android audio android-5.0-lollipop

我打算为Android制作一个均衡器应用程序。我注意到均衡器类文档 here , 它说:

NOTE: attaching an Equalizer to the global audio output mix by use of session 0 is deprecated.



我从其他问题中看到,虽然这已被弃用,但在某些 Android 版本中仍然可能;然而,最新的答案来自 2013 年。

在最新的 Android 版本(5.1 Lollipop)中,是否仍然可以通过 session 0 将均衡器附加到全局音频?如果不是,那么在 future 将均衡器应用于全局音频的推荐方法是什么?

最佳答案

根据Android ,您可以使用 ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION 来接收正在播放的 Audio Session 的 id:

Intent to signal to the effect control application or service that a new audio session is opened and requires audio effects to be applied.



我尝试在 list 中添加常量,但它仅适用于 Spotify 和 Youtube Music 等音乐应用:
<receiver android:name=".receivers.AudioSessionReceiver">
        <intent-filter>
            <action android:name="android.media.action.OPEN_AUDIO_EFFECT_CONTROL_SESSION"/>
        </intent-filter>
</receiver>

然后,您可以使用 id 创建附加到 session id 的均衡器。
public class AudioSessionReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
    int id = intent.getIntExtra(Equalizer.EXTRA_AUDIO_SESSION, -1);
    String packageName = intent.getStringExtra(Equalizer.EXTRA_PACKAGE_NAME);
}

}

关于android - 将均衡器附加到 Android 全局音频输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29531184/

相关文章:

android - OpenGL fragment 着色器正在移动对象

java - 单击监听器不会切换 Activity

html - 带有动态播放列表的HTML5 mp3 + ogg播放

java - 如何使用Azure SDK在通知中添加声音

android-5.0-lollipop - 如何取消配置设备以设置设备所有者?

java - 奇怪的 ArrayIndexOutOfBoundsException

android - 运行时异常 :Error inflating class android. support.v4.widget.DrawerLayout

python - 如何用python获得像audacity一样的音频频谱?

android - 如何在 Android L 上选择图像或视频?

android - fragment 进入过渡的问题