javascript - Toggle PlayPause Buttons in HTML Audio Player - Stack Overflow

I am after a very basic music player, I have the following basics working now, however;1) How to make b

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?

2) Also Is there anyway to add a progress counter? not a bar, but numbers i.e. 0.3/4.0min

Here is the fiddle: www.jsfiddle/tjHhY And here is the code as well here:

var audio = new Audio("/02%20Cherry%20Blossom%20Girl.mp3");

$(".play").click(function () {
    audio.play();
})

$(".pause").click(function () {
    audio.pause();
})

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?

2) Also Is there anyway to add a progress counter? not a bar, but numbers i.e. 0.3/4.0min

Here is the fiddle: www.jsfiddle/tjHhY And here is the code as well here:

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();
})
Share Improve this question edited Oct 30, 2013 at 17:29 asked Oct 30, 2013 at 17:19 user2756554user2756554 1
  • The play and pause button should also be reference by ID not class. I.E. $("#play").click.... <input type="button" id="play" /> – James McNee Commented Dec 20, 2016 at 10:53
Add a ment  | 

2 Answers 2

Reset to default 1

I'd remend you to use JQueryUI. It have nice variety of widgets to create clean interface :)

Also check this demo it shows how to create toggle play & pause button.

Hope it helps.

Why don't you check this Demo. Hope it helps :)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745547649a4632415.html

相关推荐

  • javascript - Toggle PlayPause Buttons in HTML Audio Player - Stack Overflow

    I am after a very basic music player, I have the following basics working now, however;1) How to make b

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信