Hello everyone,I got a question and I hope I'm asking in the right section.I need to put a button in a page that can switch between two audio clips. Something like that buttons that allow you to switch between image A and image B, and if you click again, it turns again to image A. Same, but with two mp3.

Hopefully the coed is easy to understand, but if you have any questions, just let me know.

koanstudio
—
2013-02-24T20:56:50Z —
#3

Hi Pullo, I really thank you for spending your time to help me, you're very kind.The code you wrote worked perfectly. But... each time you switch, the muted clip goes in pause. I know my need may sound strange but I want both clips continue even when muted (I will put two slightly different clips to compare).Thats why in the code I wrote in the first post I made both clips start in the same time.I hope this will be workable too. Thanks in advance!

Pullo
—
2013-02-25T06:49:07Z —
#4

No problem.

So, let me get this straight.You have a button.When you hit this button the first time, track one starts to play.When you hit it a second time, track one is muted (but continues playing) and track two starts to play.On every subsequent button press after this, you mute the track that is audible and unmute the one that isn't.

Is that correct?

koanstudio
—
2013-02-25T09:50:07Z —
#5

Almost correct: but both tracks should start in the same time. And end in the same time too, because I will put same tune in two different versions.I think the best way is: one button to play/pause both tracks simultaneously (independently from mute status); and another button to switch alternatively the mute status (indepenently from the play/pause status).Example: 1) I click on "play" and I listen to track one, 2) After (for example) 25 seconds I click on "switch" and I listen to track two from 25th second on, 3) I can keep on switching or I can pause and resume in every moment.This code can be useful, for example, if you put the same track, one complete, and one instrumental version. With the switch button you can toggle voice on and off.Please let me know if I didn't explain myself well.

Pullo
—
2013-02-25T11:55:36Z —
#6

Hi there,That's perfectly clear. Thanks. I'm a bit busy right now, but I'll knock some code up later on and post back here. In the mean time, if you fancy experimenting with this yourself, the HTML5 audio element has a muted property, which you can set to true or false.

koanstudio
—
2013-02-25T18:02:10Z —
#7

Please take your time, I'm already lucky enough to have such a good help from you!

This is exactly what I needed!I really thank you for your help, and I hope you didn't spend too much time to develop it.I also have to say, this forum is the only place where I could find a pro answer.

Pullo
—
2013-02-27T14:53:37Z —
#10

Not at all, it was a fun thing to code up. Thanks for taking the time to report back

dmr
—
2014-06-08T02:00:00Z —
#11

Pullo said:

Not at all, it was a fun thing to code up. Thanks for taking the time to report back