附加到MediaPlayer上的均衡器不起作用

时间:2018-12-14 09:45:54

标签: android equalizer

我正在为我的蓝牙耳机创建一个应用程序。该应用程序仅具有一个限定符和DynamicProcessing。当我将均衡器附加到MediaPlayer时,均衡器无效。 OnCreate:

mediaPlayer = MediaPlayer.create(getContext(), R.raw.testtrack);
    setupEqualizer();

这是均衡器

private void setupEqualizer() {
    mediaPlayer = new MediaPlayer();
    mediaPlayer.start();
    Log.d(TAG, "ANH HAI" + String.valueOf(mediaPlayer.getAudioSessionId()));
    mEqualizer = new Equalizer(0, mediaPlayer.getAudioSessionId());
    if (mEqualizer != null ) {
        mEqualizer.setEnabled(true);
        int num_bands = mEqualizer.getNumberOfBands();
        num_sliders = num_bands;
        short r[] = mEqualizer.getBandLevelRange();
        min_level = r[0];
        max_level = r[1];
        for (int i = 0; i < num_sliders && i < MAX_SLIDERS; i++)
        {
            //frequency band whose frequency range is requested.
            // The numbering of the bands starts from 0 and ends at (number of bands - 1).
            //the frequency range in millHertz in an array of integers.
            // The first element is the lower limit of the range, the second element the upper limit.
            mSlider[i].setOnSeekBarChangeListener(this);
        }

    }

}

我知道如果我们将audioSessionId分配为0(已弃用),则均衡器有效。 我还参考了一些参考文献,例如:https://github.com/mosamabinomar/AndroidEqualizer https://www.101apps.co.za/articles/perfect-sound-using-the-equalizer-effect-a-tutorial.html 但我没有找到答案。还有其他方法可以将均衡器附加到MediaPlayer上,该均衡器适用于Android应用播放的任何歌曲(Spotify,Youtube ...)

0 个答案:

没有答案