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.
With this code I can start/stop both clips in the same time:
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!
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.
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.
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.
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.
<audio src="http://developer.mozilla.org/@api/deki/files/2926/=AudioTest_(1).ogg" autoplay>
Your browser does not support the <code>audio</code> element.
</audio>
or
<audio src="/@api/deki/files/2926/=AudioTest_(1).ogg" autoplay>
Your browser does not support the <code>audio</code> element.
</audio>
or
<audio src="../../@api/deki/files/2926/=AudioTest_(1).ogg" autoplay>
Your browser does not support the <code>audio</code> element.
</audio>