javascript 在 HTML 音频播放器中切换播放/暂停按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19689637/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Toggle Play / Pause Buttons in HTML Audio Player
提问by webtech
I am after a very basic music player, I have the following basics working now, however;
我正在寻找一个非常基本的音乐播放器,但是我现在有以下基础工作;
1) How to make both the Play and Pause buttons in one button? That appears first as Pause and on click It toggles Play and on click again it Toggle Pause?
1) 如何让播放和暂停按钮都在一个按钮中?这首先显示为暂停,然后单击它切换播放,再次单击它切换暂停?
2) Also Is there anyway to add a progress counter? not a bar, but numbers i.e. 0.3/4.0min
2)还有无论如何要添加进度计数器?不是酒吧,而是数字,即 0.3/4.0min
Here is the fiddle: www.jsfiddle.net/tjHhYAnd here is the code as well here:
这是小提琴:www.jsfiddle.net/tjHhY这里也是代码:
var audio = new Audio("http://dp0169.free.fr/Musique/Air/Air%20-%20Talkie%20Walkie/02%20Cherry%20Blossom%20Girl.mp3");
$(".play").click(function () {
audio.play();
})
$(".pause").click(function () {
audio.pause();
})