我在 webview 中播放 Flash。是否可以将动画声音静音?
我的活动也可以播放音乐文件,所以我设置:
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
有什么关系吗?
我在 webview 中播放 Flash。是否可以将动画声音静音?
我的活动也可以播放音乐文件,所以我设置:
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
有什么关系吗?
我使用 setStreamVolume 而不是 setStreamMute,以便在取消音量 = 0 时能够将音量设置为最大值
    /**
 * Set sound state
 * @param soundOn new sound state
 */
private void setSoundState(boolean soundOn) {
    // set sound param
    mGlobalData.SoundOn = soundOn;
    AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
    if (soundOn) {
        // restore old volume
        int newVoume = mGlobalData.oldSoundVolume;
        if (newVoume == 0)
            newVoume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
        mSoundIcon.setImageResource(R.drawable.sound_on);
        audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,newVoume, 0);
        //mMediaPlayer.setVolume(0, 1);
    } else {
        mSoundIcon.setImageResource(R.drawable.sound_off);
        mGlobalData.oldSoundVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
        audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,0, 0);
        //mMediaPlayer.setVolume(0, 0);
    }
}
    如果您想静音设备任何流的声音,请使用
public void setStreamMute (int streamType, boolean state)
例子 :
myAudioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);