Android的 - 均衡器使用preSET不工作(在声音效果不变) [英] Android - Equalizer usePreset not working (No change in sound effect)

查看:653
本文介绍了Android的 - 均衡器使用preSET不工作(在声音效果不变)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作流媒体广播的应用程序。一切正常,除了不断变化的均衡器效果,不影响声音。

I am working on streaming radio application. everything is working fine except the changing the equalizer effect does not affect sound.

通过调用使用preSET(preSET)不会使声音效果的任何变化而变化的均衡器效果。

Changing the equalizer effect by calling usePreset(preset) does not make any changes in the sound effects.

即使没有错误,为什么要使用preSET不会改变声音效果。

Even though there is no error, why usePreset does not change the sound effects.

我在三星Galaxy SII与4.0.3进行测试。

I have tested in samsung galaxy sII with 4.0.3.

public void startPlayer() {
    //
    // Check whether we can acquire the audio focus
    // to start the player
    //
    if (!requestAudioFocus()) {
        return;
    }

    if (null != mAudioPlayer) {
        if (mAudioPlayer.isPlaying()) {
            mAudioPlayer.stop();
        }
        mAudioPlayer.reset();
    } else {
        mAudioPlayer = new MediaPlayer();
        mAudioPlayer.reset();
    }
    try {
        notifyProgressUpdate(PLAYER_INITIALIZING);
        try {
            mEqualizer = new Equalizer(0, mAudioPlayer.getAudioSessionId());
            mEqualizer.setEnabled(true);
            Log.d(TAG,
                    "Audio Session ID " + mAudioPlayer.getAudioSessionId()
                            + "Equalizer " + mEqualizer + " Preset "
                            + mEqualizer.getCurrentPreset());
        } catch (Exception ex) {
            mEqualizer = null;
        }
        mAudioPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mAudioPlayer.setDataSource(mCurrentTrack.getStreamURL());

        //
        // Add the Listener to track the player status
        //
        mAudioPlayer.setOnCompletionListener(this);
        mAudioPlayer.setOnBufferingUpdateListener(this);
        mAudioPlayer.setOnPreparedListener(this);
        mAudioPlayer.setOnInfoListener(this);
        mAudioPlayer.setOnErrorListener(this);
        notifyProgressUpdate(PLAYER_BUFFERING);
        mAudioPlayer.prepareAsync();

    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

            //Get the available presets from the equalizer
    public String[] getEqualizerPresets() {
        String[] presets = null;
        short noOfPresets = -1;
        if (null != mEqualizer) {
            noOfPresets = mEqualizer.getNumberOfPresets();
            presets = new String[noOfPresets];
            for (short index = 0; index < noOfPresets; index++) {
                presets[index] = mEqualizer.getPresetName(index);
            }
        }
        return presets;
    }

            //Set the user preferred presets
    public void setEqualizerPreset(int position) {
        if (null != mEqualizer) {
            Log.d(TAG, "setting equlizer effects " + position);
            Log.d(TAG, "Equalizer " + mEqualizer + " set Preset " + position);
            mEqualizer.usePreset((short)position);
            Log.d(TAG, "Equalizer " + mEqualizer + " current Preset "
                    + mEqualizer.getCurrentPreset());
        }
    }

鸭preciate你的帮助,以确定问题。

Appreciate your help to identify the issue.

修改 这个问题没有解决呢。我没有发现任何样本code这解释了均衡器preSET使用。

EDIT This issue is not resolved yet. i did not find any sample code which explain Equalizer Preset usage.

凡提及code样品,它使用preset的欢迎。

Any reference to code sample which uses Preset welcome.

推荐答案

这是一个完全源$ C ​​$下均衡器,希望这将帮助你。

这篇关于Android的 - 均衡器使用preSET不工作(在声音效果不变)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆