var pauseEle = document.getElementById("pause"); var stopEle = document.getElementById("stop"); var minusEle = document.getElementById("minus"); var addEle = document.getElementById("add"); var quietEle = document.getElementById("quiet"); pauseEle.onclick = function(){ if(pauseEle.innerText === '暂停' ){ test.pauseAudio(); pauseEle.innerText = '继续'; }else{ test.playAudio(); pauseEle.innerText = '暂停'; } } stopEle.onclick = function(){ if(stopEle.innerText === '停止'){ test.stopAudio() stopEle.innerText = '开始'; }else{ test.startAudio() stopEle.innerText = '停止' } } minusEle.onclick = function(){ addEle.disabled = false; if(test.getVolume() < 10 ){ minusEle.disabled = true; }else{ test.decVolume() } } addEle.onclick = function(){ minusEle.disabled = false; if(test.getVolume() > 90 ){ addEle.disabled = true; }else{ test.ascVolume() } } quietEle.onclick = function(){ if(quietEle.innerText === '静音'){ test.quietVolume(); quietEle.innerText = '取消静音' } else{ test.recoverVolume(); quietEle.innerText = '静音' } }增加播放暂停图片切换
时间: 2024-03-24 14:38:36 浏览: 113
您可以在 `if` 和 `else` 语句中添加切换图片的代码,例如:
```javascript
var pauseEle = document.getElementById("pause");
var stopEle = document.getElementById("stop");
var minusEle = document.getElementById("minus");
var addEle = document.getElementById("add");
var quietEle = document.getElementById("quiet");
var audioImg = document.getElementById("audio-img");
pauseEle.onclick = function() {
if (pauseEle.innerText === '暂停') {
test.pauseAudio();
pauseEle.innerText = '继续';
audioImg.src = 'pause.png';
} else {
test.playAudio();
pauseEle.innerText = '暂停';
audioImg.src = 'play.png';
}
}
stopEle.onclick = function() {
if (stopEle.innerText === '停止') {
test.stopAudio();
stopEle.innerText = '开始';
audioImg.src = 'stop.png';
} else {
test.startAudio();
stopEle.innerText = '停止';
audioImg.src = 'play.png';
}
}
// 其他按钮的代码不再赘述
```
其中,`audioImg` 是你需要切换图片的元素,可以根据实际情况修改。`play.png`、`pause.png` 和 `stop.png` 是你需要切换的图片。
阅读全文