javascript - 根据媒体是播放还是暂停来更改按钮的文本?

标签 javascript html audio video

我的代码部分有效。当我单击播放时,它会更改为暂停,但是当我单击暂停后立即保持为暂停状态,并且不会更改回播放吗?

var playOrPause = function (id, button) {
var pp = document.getElementById(id);
    if(pp.paused) {
        button.textContent = 'Play';
    } else if(!pp.paused) {
        button.textContent = 'Pause';
    }
};

我只是想出我的问题。我对我的事件监听器之一进行了错误的编码大声笑谢谢大家的帮助!

最佳答案

$('.player_audio').click(function() {if (this.paused == false) { this.pause();
  alert('music paused'); } else { this.play();alert('music playing');}});

这对你有帮助

关于javascript - 根据媒体是播放还是暂停来更改按钮的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35546890/

相关文章:

javascript - jQuery解析JSON问题/按字母顺序对<option>进行排序

javascript - 这段 JavaScript 代码中的 '&&' 表达式是什么意思?

javascript - 修改并显示使用D3生成的表中的缩写数据

javascript - 错误: Auto count the adding of textbox which is not supposed to be

python - 使用 BeautifulSoup 抓取标签之间的文本

html - 在单页应用程序中将页脚设置为底部

audio - 如何保留从 Websocket 调用到 Bluemix Speech2text 服务的音频?

image - JHipster : Blob/ImageBlob/VideoBlob/AudioBlob datatype

javascript - fs.readdir 和 fs.readfile 和正则表达式

javascript - 如何使用 javascript 从 Audio Element 录制音频