I play an mp3 file, just javascript onClick.
Below is my code:
//Music File 1 <audio id="id1" src="01.mp3"></audio> <button onClick="document.getElementById("id1").play()">Play</button> <button onClick="document.getElementById("id1").pause()">Stop</button> //Music File 2 <audio id="id2" src="02.mp3"></audio> <button onClick="document.getElementById("id2").play()">Play</button> <button onClick="document.getElementById("id2").pause()">Stop</button>
My question is: I play music 01.mp3 and I want her to stop playing if I press the play button in music 02.mp3.
Can someone give me a better solution than this? In general, I want to play music, for example, www.mp3skull.com, another stop if you click another file to play.
Regards, Virak
source share