如何静音/控制WebView / Flash卷?

时间:2012-08-13 14:36:33

标签: android flash android-webview

我在网页浏览中播放Flash。 是否可以将动画声音静音?

我的活动也可以播放音乐文件,所以我设置:

this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

它有点相关吗?

2 个答案:

答案 0 :(得分:2)

我使用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);
    }
}

答案 1 :(得分:0)

如果要将设备的任何信息流静音,请使用

public void setStreamMute (int streamType, boolean state)

示例:

myAudioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);