Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.79 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <meta charset="utf-8">
  4.     <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
  5.     <style>
  6.         audio {
  7.             background: red;
  8.         }
  9.         .time-stripe {
  10.             height: 10px;
  11.             background: black;
  12.             width: 0;
  13.         }
  14.  
  15.         button {
  16.             width: 30px;
  17.             height: 30px;
  18.             border-radius: 50%;
  19.         }
  20.     </style>
  21. </head>
  22. <body>
  23. <audio controls src="sample.mp3" class="audio-player">
  24.     update your browser
  25. </audio><br/>
  26. <input type="checkbox" class="player-mute" checked><br/>
  27. <button class="button-play"><i class="fa fa-play"></i></button>
  28. <button class="button-pause"><i class="fa fa-pause"></i></button>
  29. <button class="button-stop"><i class="fa fa-stop"></i></button>
  30. <input class="volume" type="range" min="0" max="1" step="0.1" value=1>
  31. <div class="time-stripe"></div>
  32. <script>
  33.     const player = document.getElementsByClassName('audio-player')[0];
  34.     const stripe = document.getElementsByClassName('time-stripe')[0];
  35.  
  36.     document.getElementsByClassName('button-play')[0].onclick = function() {
  37.         player.play();
  38.     }
  39.  
  40.     document.getElementsByClassName('button-pause')[0].onclick = function() {
  41.         player.pause();
  42.     }
  43.  
  44.     document.getElementsByClassName('button-stop')[0].onclick = function() {
  45.         player.pause();
  46.         player.currentTime = 0;
  47.     }
  48.  
  49.     document.getElementsByClassName('volume')[0].oninput = function() {
  50.         player.volume = this.value;
  51.     }
  52.  
  53.     player.ontimeupdate = function() {
  54.         stripe.style.width = (player.currentTime / player.duration * 100) + '%';
  55.     }
  56. </script>
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement