este es el código q estoy utilizando:
javascript:
Código HTML:
<head> <script type="text/javascript"> function playPause(){ var reproduciendo = true; var pista = document.getElementById('nosemeocurre'); var boton_play_pause = document.getElementById('boton_play_pause'); boton_play_pause.onclick = function(){ if(reproduciendo){ reproduciendo = false; pista.play(); this.value = 'PLAY'; }else{ reproduciendo = true; pista.pause(); this.value = 'PAUSE'; } } } /*function play2(){ var reproduciendo = true; var pista = document.getElementById('nosemeocurre2'); var boton_play_pause = document.getElementById('boton_play_pause2'); boton_play_pause.onclick = function(){ if(reproduciendo){ reproduciendo = false; pista.play(); this.value = 'PLAY'; }else{ reproduciendo = true; pista.pause(); this.value = 'PAUSE'; } } }*/ window.onload = function(){ playPause(); play2(); } </script> </head>
Código HTML:
<p> <audio id="nosemeocurre" src="sonido1.mp3"><br> </audio><br> <img id="boton_play_pause" src="imagen1.jpg" sizes="(max-width: 500px) 100vw, 500px" srcset="imagen1.jpg 500w, imagen1.jpg 150w, imagen1.jpg" alt="" width="500" height="500"> </p> <p><audio id="nosemeocurre2" src="sonido2.mp3"></audio><br> <img id="boton_play_pause" src="imagen2.jpg" sizes="(max-width: 500px) 100vw, 500px" srcset="imagen2.jpg 500w, imagen2.jpg 150w, imagen2.jpg" alt="" width="500" height="500"></p>