我在这里创建了一个我的函数的小提琴(http://jsfiddle.net/rhy5K/10/)。现在我想为用户提供声音“静音/不可见”选项。例如,如果我的“点击一个链接,然后声音播放像应该是静音,反之亦然。如何使用javascript将音频静音/取消静音
我想喜欢叫上点击toggle_sound
功能,但我混淆像我应该写什么在函数内部。要静音
请提供给我一个逻辑,或对我的问题的解决方案
说明使用的代码示例:
我想静音/取消静音下面这个声音播放
var playGetReady = function (done) {
var ids = ['audiosource', 'a_5', 'a_4', 'a_3', 'a_2', 'a_1'],
playNext = function() {
var id = ids.shift();
document.getElementById(id).play();
if (ids.length) {
setTimeout(playNext, 1000);
} else {
done();
}
};
playNext();
};
警告:这个js小提琴演示播放声音负载
使用'的document.getElementById(id)的.setVolume(0);'静音 – Ian
或'的document.getElementById( id).muted = true;' – Oliboy50
http://stackoverflow.com/questions/10075909/how-to-set-the-loudness-of-html5-audio或http://stackoverflow.com/questions/13937118/set -volume-html-5-audio-tag-with-javascript – Alex