luistavares

HTML e JavaScript - Reproduzindo áudio

Sep 19th, 2022
2,879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.65 KB | None | 0 0
  1. <html>
  2.     <script>
  3.         function playAudio() {
  4.             let x = document.getElementById("myAudio");
  5.             x.play();
  6.         }
  7.         function pauseAudio() {
  8.             let x = document.getElementById("myAudio");
  9.             x.pause();
  10.         }      
  11.     </script>
  12.     <body>
  13.         <h3>Controlando audio com JS</h3>
  14.         <audio id="myAudio" controls>
  15.             <source src="beethoven.mp3" type="audio/mpeg">
  16.             Seu navegador não possui suporte ao elemento audio
  17.         </audio><br><br>
  18.         <button onclick="playAudio()">Play</button>
  19.         <button onclick="pauseAudio()">Pause</button>
  20.     </body>
  21. </html>
Advertisement
Add Comment
Please, Sign In to add comment