Advertisement
Sky_Blue

music player by @puella

Jun 20th, 2021 (edited)
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.29 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <head>
  3.  
  4. <!-----
  5.  
  6. music player by @puella. credit is not necessary, but it is appreciated! <3
  7.  
  8. ----->
  9.  
  10. <!-- this is needed, do not change!!! -->
  11. <script src="https://kit.fontawesome.com/f936906ae0.js" crossorigin="anonymous"></script>
  12.  
  13. </head>
  14. <style>
  15.  
  16. #musicplayer{
  17.     width:450px; /* width of the music player */
  18.     border: 2px solid black; /* border around the music player */
  19.     background:white; /* background color of the music player */
  20. }
  21.  
  22. /* no change needed */
  23. .controls{
  24.     padding:5px;
  25.     font-size:15px !important;
  26. }
  27.  
  28. .songtitle{
  29.     width:400px;
  30.     font-size:20px !important; /* font size of the song title */
  31.     padding-right:10px;
  32.     display:flex;
  33. }
  34.  
  35. i.fas:hover{
  36.     cursor:help;
  37. }
  38.  
  39. i.fas.fa-pause{
  40.     border:1px solid black; /* border around pause button */
  41.     padding:10px;
  42.     background:white; /* background color of the pause button */
  43.     color:black; /* color of the pause button */
  44. }
  45.  
  46. i.fas.fa-play{
  47.     border:1px solid black; /* border around play button */
  48.     padding:10px;
  49.     background:white; /* background color of the play button */
  50.     color:black; /* color of the play button */
  51. }
  52.    
  53. </style>
  54. <body>
  55.  
  56. <!-- music player -->
  57. <div id="musicplayer">
  58.     <table>
  59.         <tr>
  60.             <td>
  61.                 <div class="controls"><div class="play" style="display:inline-block"><i class="fas fa-play" onclick="play()"></i></div></div>
  62.             </td>
  63.             <td>
  64.             <!-- song title goes here --> <div class="songtitle"><marquee scrollamount="10">SONG TITLE HERE</marquee></div>
  65.             </td>
  66.         </tr>
  67.     </table>
  68.     <!-- mp3 goes here --> <audio id="music" src="MP3 LINK HERE"></audio>
  69. </div>
  70.  
  71. <!-- javascript, do not change below this!! -->
  72. <script>
  73. let player = document.getElementById("music");
  74.  
  75. function play(){
  76.     player.play();
  77.     document.querySelector('.play').innerHTML = "<i class='fas fa-pause' onclick='pause()'></i>";
  78. }
  79.  
  80. function pause(){
  81.     player.pause();
  82.     document.querySelector('.play').innerHTML = "<i class='fas fa-play' onclick='play()'></i>";
  83. }
  84.  
  85. player.onended = function(){
  86.     document.querySelector('.play').innerHTML = "<i class='fas fa-play' onclick='play()'></i>";
  87. }
  88. </script>
  89. <!-- javascript, do not change above this -->
  90.  
  91. </body>
  92. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement