izuemis

cr akustqr music player | cr adilene for the og

Mar 21st, 2023
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.83 KB | None | 0 0
  1. <head>
  2. <script src="https://unpkg.com/phosphor-icons"></script>
  3.  
  4. <style>
  5. @font-face {
  6. font-family: Nintendo-DS-BIOS;
  7. src: url(https://dl.dropbox.com/s/vlxjtnvrl9s0snp/Nintendo-DS-BIOS.ttf);
  8. }
  9.  
  10. #musicplayer {
  11. position: relative;
  12. top: 5px;
  13. }
  14.  
  15. .songtitle {
  16. font-family: Nintendo-DS-BIOS;
  17. font-size: 1em;
  18. color: white;
  19. -webkit-filter: drop-shadow(0px 0px 1px #525252);
  20. }
  21.  
  22. .controls {
  23. font-size: 18px !important;
  24. text-align: center;
  25. width: 100%;
  26. }
  27.  
  28. .controls td {
  29. padding: 0px 5px 0px 5px;
  30. }
  31.  
  32. .seeking {
  33. display: flex;
  34. justify-content: space-evenly;
  35. }
  36.  
  37. .current-time {
  38. padding-right: 5px;
  39. font-family: Nintendo-DS-BIOS;
  40. font-size: 1em;
  41. color: white;
  42. }
  43.  
  44. .total-duration {
  45. padding-left: 5px;
  46. font-family: Nintendo-DS-BIOS;
  47. font-size: 1em;
  48. color: white;
  49. }
  50.  
  51. input[type=range] {
  52. -webkit-appearance: none;
  53. width: 100%;
  54. background-color: transparent;
  55. }
  56.  
  57. input[type=range]:focus {
  58. outline: none;
  59. }
  60.  
  61. input[type=range]::-webkit-slider-runnable-track {
  62. width: 100%;
  63. height: 2px;
  64. cursor: help;
  65. animate: 0.2s;
  66. background: white;
  67. border-radius: 1px;
  68. }
  69.  
  70. input[type=range]::-webkit-slider-thumb {
  71. border: 0px solid #000;
  72. height: 10px;
  73. width: 10px;
  74. border-radius: 10px;
  75. background: white;
  76. cursor: help;
  77. -webkit-appearance: none;
  78. margin-top: -4px;
  79. }
  80.  
  81. input[type=range]:focus::-webkit-slider-runnable-track {
  82. background: white;
  83. }
  84.  
  85. input[type=range]::-moz-range-track {
  86. width: 100%;
  87. height: 2px;
  88. cursor: help;
  89. animate: 0.2s;
  90. background: white;
  91. border-radius: 1px;
  92. }
  93.  
  94. input[type=range]::-moz-range-thumb {
  95. border: 0px solid #000;
  96. height: 10px;
  97. width: 10px;
  98. border-radius: 10px;
  99. background: white;
  100. cursor: help;
  101. }
  102.  
  103. input[type=range]::-ms-track {
  104. width: 100%;
  105. height: 2px;
  106. cursor: help;
  107. animate: 0.2s;
  108. background: transparent;
  109. border-color: transparent;
  110. color: transparent;
  111. }
  112.  
  113. input[type=range]::-ms-fill-lower {
  114. background: white;
  115. border-radius: 2px;
  116. }
  117.  
  118. input[type=range]::-ms-fill-upper {
  119. background: white;
  120. border-radius: 2px;
  121. }
  122.  
  123. input[type=range]::-ms-thumb {
  124. margin-top: 1px;
  125. border: 0px solid #000;
  126. height: 10px;
  127. width: 10px;
  128. border-radius: 10px;
  129. background: white;
  130. cursor: help;
  131. }
  132.  
  133. input[type=range]:focus::-ms-fill-lower {
  134. background: white;
  135. }
  136.  
  137. input[type=range]:focus::-ms-fill-upper {
  138. background: white;
  139. }
  140. </style>
  141. </head>
  142.  
  143. <body>
  144. <div id="musicplayer">
  145. <div>
  146.  
  147. <div class="songtitle"></div>
  148.  
  149. <table class="controls">
  150. <tr>
  151. <td>
  152. <div class="prev-track" onclick="prevTrack()"><i class="ph-skip-back-fill" style="color: white"></i></div>
  153. </td>
  154. <td>
  155. <div class="playpause-track" onclick="playpauseTrack()" ><i class="ph-play-fill" style="color: white"></i></div>
  156. </td>
  157. <td>
  158. <div class="next-track" onclick="nextTrack()"><i class="ph-skip-forward-fill" style="color: white"></i></div>
  159. </td>
  160. </tr>
  161. </table>
  162.  
  163. <div class="seeking">
  164. <div class="current-time">00:00</div>
  165.  
  166. <input type="range" min="1" max="100" value="0" class="seek_slider" onchange="seekTo()">
  167.  
  168. <div class="total-duration">0:00</div>
  169. </div>
  170.  
  171. <audio id="music" src=""></audio>
  172. </div>
  173. </div>
  174.  
  175. <script>
  176. let track_name = document.querySelector(".songtitle");
  177.  
  178. let playpause_btn = document.querySelector(".playpause-track");
  179. let next_btn = document.querySelector(".next-track");
  180. let prev_btn = document.querySelector(".prev-track");
  181.  
  182. let seek_slider = document.querySelector(".seek_slider");
  183. let curr_time = document.querySelector(".current-time");
  184. let total_duration = document.querySelector(".total-duration");
  185.  
  186. let track_index = 0;
  187. let isPlaying = false;
  188. let updateTimer;
  189.  
  190. // Create new audio element
  191. let curr_track = document.getElementById("music");
  192.  
  193. //
  194. // DEFINE YOUR SONGS HERE!!!!!
  195. // MORE THAN FOUR SONGS CAN BE ADDED!!
  196. // JUST ADD ANOTHER BRACKET WITH NAME AND PATH
  197. // CATBOX.MOE IS RECOMMENDED FOR UPLOADING MP3 FILES
  198. let track_list = [
  199. {
  200. name:"IDSMILE - 25:00 at Nightcord",
  201. path:"https://cdn.discordapp.com/attachments/1011654612551487558/1028535519346442260/25-ji_Nightcord_de_x_MEIKO_-_ID_Smile_Color_Coded_Kan_Rom_Eng_Lyrics_Project_Sekai.mp3"
  202. },
  203. {
  204. name:"inabakumori feat. kaai yuki - kimi ni kaikisen",
  205. path:"https://files.catbox.moe/1pxdnw.mp3"
  206. },
  207. {
  208. name:"pinocchio-p feat. hatsune miku - god-ish",
  209. path:"https://files.catbox.moe/xv3vdj.mp3"
  210. },
  211. {
  212. name: "syudou feat. hatsune miku - her boyfriend, jude",
  213. path: "https://files.catbox.moe/49iuxl.mp3",
  214. },
  215. ];
  216.  
  217. function loadTrack(track_index) {
  218. clearInterval(updateTimer);
  219. resetValues();
  220.  
  221. // Load a new track
  222. curr_track.src = track_list[track_index].path;
  223. curr_track.load();
  224.  
  225. // Set an interval of 1000 milliseconds for updating the seek slider
  226. updateTimer = setInterval(seekUpdate, 1000);
  227.  
  228. // Move to the next track if the current one finishes playing
  229. curr_track.addEventListener("ended", nextTrack);
  230.  
  231. }
  232.  
  233. // Reset Values
  234. function resetValues() {
  235. curr_time.textContent = "0:00";
  236. total_duration.textContent = "0:00";
  237. seek_slider.value = 0;
  238. }
  239.  
  240. function playpauseTrack() {
  241. if (!isPlaying) playTrack();
  242. else pauseTrack();
  243. }
  244.  
  245. function playTrack() {
  246. curr_track.play();
  247. isPlaying = true;
  248.  
  249. // Replace icon with the pause icon
  250. playpause_btn.innerHTML = '<i class="ph-pause-fill" style="color: white"></i>';
  251. }
  252.  
  253. function pauseTrack() {
  254. curr_track.pause();
  255. isPlaying = false;
  256.  
  257. // Replace icon with the play icon
  258. playpause_btn.innerHTML = '<i class="ph-play-fill" style="color: white"></i>';
  259. }
  260.  
  261. function nextTrack() {
  262. if (track_index < track_list.length - 1)
  263. track_index += 1;
  264. else track_index = 0;
  265. loadTrack(track_index);
  266. playTrack();
  267. }
  268.  
  269. function prevTrack() {
  270. if (track_index > 0)
  271. track_index -= 1;
  272. else track_index = track_list.length;
  273. loadTrack(track_index);
  274. playTrack();
  275. }
  276.  
  277. function seekTo() {
  278. seekto = curr_track.duration * (seek_slider.value / 100);
  279. curr_track.currentTime = seekto;
  280. }
  281.  
  282. function seekUpdate() {
  283. let seekPosition = 0;
  284.  
  285. // Check if the current track duration is a legible number
  286. if (!isNaN(curr_track.duration)) {
  287. seekPosition = curr_track.currentTime * (100 / curr_track.duration);
  288. seek_slider.value = seekPosition;
  289.  
  290. // Calculate the time left and the total duration
  291. let currentMinutes = Math.floor(curr_track.currentTime / 60);
  292. let currentSeconds = Math.floor(curr_track.currentTime - currentMinutes * 60);
  293. let durationMinutes = Math.floor(curr_track.duration / 60);
  294. let durationSeconds = Math.floor(curr_track.duration - durationMinutes * 60);
  295.  
  296. // Adding a zero to the single digit time values
  297. if (currentSeconds < 10) { currentSeconds = "0" + currentSeconds; }
  298. if (durationSeconds < 10) { durationSeconds = "0" + durationSeconds; }
  299. if (currentMinutes < 10) { currentMinutes = currentMinutes; }
  300. if (durationMinutes < 10) { durationMinutes = durationMinutes; }
  301.  
  302. curr_time.textContent = currentMinutes + ":" + currentSeconds;
  303. total_duration.textContent = durationMinutes + ":" + durationSeconds;
  304. }
  305. }
  306.  
  307. // Load the first track in the tracklist
  308. loadTrack(track_index);
  309. </script>
  310. </body>
Add Comment
Please, Sign In to add comment