<style>
/* MP3 Player - Scoped Styles (Only affects .player) */
.player * {
box-sizing: border-box;
}
.player {
width: fit-content;
margin-left: auto;
margin-right: auto;
}
/* All styles are scoped under .player */
.player .window,
.player .title-bar {
font-family: "Pixelated MS Sans Serif", Arial;
-webkit-font-smoothing: none;
font-size: 11px;
}
.player .window {
box-shadow: inset -1px -1px #0a0a0a,
inset 1px 1px #dfdfdf, inset -2px -2px #808080,
inset 2px 2px #ffffff;
background: #c0c0c0;
padding: 3px;
width: 260px;
}
.player .title-bar {
padding: 3px 2px 3px 3px;
display: flex;
justify-content: space-between;
align-items: center;
background: linear-gradient(to right, #613574 0%, #C0C0C0 100%);
}
.player .title-bar-text {
font-weight: bold;
color: white;
letter-spacing: 0;
margin-right: 24px;
font-size: 11px;
}
.player .title-bar-controls {
display: flex;
}
.player .title-bar-controls button {
padding: 0;
display: block;
min-width: 16px;
min-height: 14px;
background: silver;
border: none;
border-radius: 0;
box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px grey, inset 2px 2px #dfdfdf;
font-size: 11px;
color: transparent;
text-shadow: none;
}
.player .title-bar-controls button:active {
box-shadow: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px grey;
}
.player .title-bar-controls button[aria-label="Minimize"] {
background-image: url("https://raw.githubusercontent.com/jdan/98.css/main/icon/minimize.svg");
background-position: bottom 3px left 4px;
background-repeat: no-repeat;
}
.player .title-bar-controls button[aria-label="Maximize"] {
background-image: url("https://raw.githubusercontent.com/jdan/98.css/4a2282dd9170cabf730fb5803d1153d86b2e94e3/icon/maximize.svg");
background-position: top 2px left 3px;
background-repeat: no-repeat;
}
.player .title-bar-controls button[aria-label="Close"] {
background-image: url("https://raw.githubusercontent.com/jdan/98.css/main/icon/close.svg");
background-position: top 3px left 4px;
background-repeat: no-repeat;
margin-left: 2px;
}
.player .window-body {
margin: 0px;
height: 98px;
}
.player .flex {
display: flex;
}
.player #imagestyle {
background: silver;
border: 2px solid silver;
width: 95px;
height: 95px;
box-shadow: inset -1px -1px #fff, inset 1px 1px grey, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a;
}
.player .ic {
width: 90px;
position: relative;
bottom: 1px;
right: 1px;
overflow: hidden;
padding: 2px;
border: 2px solid transparent;
}
.player .titlebaricon {
height: 14px;
width: 14px;
}
.player #musicplayer {
border: 2px solid silver;
border-width: 2px 0px 0px 0px;
width: 160px;
}
.player .songtitlewindow {
background-color: #fff;
box-shadow: inset -1px -1px #fff, inset 1px 1px grey, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a;
}
.player .songtitlearrow {
background-size: 100%;
background-repeat: no-repeat;
background-image: url(https://files.catbox.moe/f5e8np.png);
height: 21px;
width: 21px;
position: relative;
top: 2px;
left: -2px;
border: 0px solid transparent;
}
.player .songtitle {
padding: 5px;
border-bottom: 0px;
display: block;
font-family: "Pixelated MS Sans Serif", Arial;
font-size: 11px;
color: #000;
}
.player .controls {
font-size: 18px !important;
text-align: center;
width: 100%;
position: relative;
bottom: 10px;
}
.player .controls td {
padding: 8px 5px 0px 5px;
}
.player .controls button {
min-width: 40px;
background: silver;
border: none;
border-radius: 0;
box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px grey, inset 2px 2px #dfdfdf;
padding: 4px 8px;
font-size: 11px;
color: #000;
cursor: pointer;
}
.player .controls button:active {
box-shadow: inset -1px -1px #fff, inset 1px 1px #0a0a0a, inset -2px -2px #dfdfdf, inset 2px 2px grey;
}
.player .controlimg {
height: 15px;
width: 15px;
display: block;
}
.player .seeking {
background-color: #c0c0c0;
display: flex;
justify-content: space-evenly;
padding: 14px;
align-items: center;
}
.player .current-time,
.player .total-duration {
font-family: "Pixelated MS Sans Serif", Arial;
font-size: 11px;
color: #000;
}
.player input[type="range"] {
-webkit-appearance: none;
appearance: none;
width: 100%;
background: transparent;
margin: 0 5px;
}
.player input[type="range"]:focus {
outline: none;
}
.player input[type="range"]::-webkit-slider-runnable-track {
width: 100%;
height: 2px;
box-sizing: border-box;
background: black;
border-right: 1px solid grey;
border-bottom: 1px solid grey;
box-shadow: 1px 0 0 white, 1px 1px 0 white, 0 1px 0 white, -1px 0 0 darkgrey,
-1px -1px 0 darkgrey, 0 -1px 0 darkgrey, -1px 1px 0 white, 1px -1px darkgrey;
}
.player input[type="range"]::-moz-range-track {
width: 100%;
height: 2px;
box-sizing: border-box;
background: black;
border-right: 1px solid grey;
border-bottom: 1px solid grey;
box-shadow: 1px 0 0 white, 1px 1px 0 white, 0 1px 0 white, -1px 0 0 darkgrey,
-1px -1px 0 darkgrey, 0 -1px 0 darkgrey, -1px 1px 0 white, 1px -1px darkgrey;
}
.player input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
height: 21px;
width: 11px;
background: url("https://raw.githubusercontent.com/jdan/98.css/main/icon/indicator-horizontal.svg");
transform: translateY(-8px);
box-shadow: none;
border: none;
}
.player input[type="range"]::-moz-range-thumb {
height: 21px;
width: 11px;
border: 0;
border-radius: 0;
background: url("https://raw.githubusercontent.com/jdan/98.css/main/icon/indicator-horizontal.svg");
transform: translateY(2px);
}
@font-face {
font-family: "Pixelated MS Sans Serif";
src: url("https://files.catbox.moe/1za99g.woff") format("woff");
src: url("https://files.catbox.moe/8fwbkl.woff2") format("woff2");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "Pixelated MS Sans Serif";
src: url("https://files.catbox.moe/z7csle.woff") format("woff");
src: url("https://files.catbox.moe/moqhx6.woff2") format("woff2");
font-weight: bold;
font-style: normal;
}
</style>
<div class="player">
<div class="window">
<div class="title-bar">
<div class="title-bar-text"><sub><img class="titlebaricon" src="https://files.catbox.moe/tg55zp.png" alt="cd player icon" /></sub> CD player</div>
<div class="title-bar-controls">
<button aria-label="Minimize"></button>
<button aria-label="Maximize"></button>
<button aria-label="Close"></button>
</div>
</div>
<div class="window-body">
<div class="flex">
<div id="imagestyle"><img class="ic" src="https://i.pinimg.com/736x/de/0f/cd/de0fcd818924383d4d6964fa282a386a.jpg" /></div>
<div id="musicplayer">
<div class="songtitlewindow">
<div class="flex"><marquee scrollamount="4" class="songtitle"></marquee><div class="songtitlearrow"></div></div>
</div>
<div class="seeking">
<div class="current-time">00:00</div>
<input type="range" min="1" max="100" value="0" class="seek_slider" />
<div class="total-duration">0:00</div>
</div>
<table class="controls">
<tr>
<td><button class="prev-track"><img src="https://files.catbox.moe/hhoh1h.png" class="controlimg" /></button></td>
<td><button class="playpause-track"><img src="https://files.catbox.moe/w93riq.png" class="controlimg" /></button></td>
<td><button class="next-track"><img src="https://files.catbox.moe/p4q9gf.png" class="controlimg" /></button></td>
</tr>
</table>
<audio id="music" src=""></audio>
</div>
</div>
</div>
</div>
</div>
<script>
(function() {
// initiate variables
let track_name = document.querySelector(".player .songtitle");
let playpause_btn = document.querySelector(".player .playpause-track");
let next_btn = document.querySelector(".player .next-track");
let prev_btn = document.querySelector(".player .prev-track");
let seek_slider = document.querySelector(".player .seek_slider");
let curr_time = document.querySelector(".player .current-time");
let total_duration = document.querySelector(".player .total-duration");
let track_index = 0;
let isPlaying = false;
let updateTimer;
let curr_track = document.getElementById("music");
// YOUR SONGS HERE
let track_list = [{
name: "The Bitch Is Back - Elton John",
path: "https://files.catbox.moe/51ihi8.mp3"
}, {
name: "Black Sheep - Metric",
path: "https://files.catbox.moe/29gs6t.mp3"
}, {
name: "My Life - Billy Joel",
path: "https://files.catbox.moe/udxi9c.mp3"
}, {
name: "One Way Or Another - Blondie",
path: "https://files.catbox.moe/pipce1.mp3"
}, {
name: "I Love Rock 'N Roll - Joan Jett and the Blackhearts",
path: "https://files.catbox.moe/ozwr2w.mp3"
}];
function loadTrack(index) {
clearInterval(updateTimer);
resetValues();
curr_track.src = track_list[index].path;
curr_track.load();
track_name.textContent = "playing " + (index + 1) + " of " + track_list.length + ": " + track_list[index].name;
updateTimer = setInterval(seekUpdate, 1000);
curr_track.addEventListener("ended", nextTrack);
}
function resetValues() {
curr_time.textContent = "0:00";
total_duration.textContent = "0:00";
seek_slider.value = 0;
}
function playpauseTrack() {
if (!isPlaying) playTrack();
else pauseTrack();
}
function playTrack() {
curr_track.play();
isPlaying = true;
playpause_btn.innerHTML = '<img src="https://files.catbox.moe/njer0s.png" class="controlimg" />';
}
function pauseTrack() {
curr_track.pause();
isPlaying = false;
playpause_btn.innerHTML = '<img src="https://files.catbox.moe/w93riq.png" class="controlimg" />';
}
function nextTrack() {
track_index = (track_index < track_list.length - 1) ? track_index + 1 : 0;
loadTrack(track_index);
playTrack();
}
function prevTrack() {
track_index = (track_index > 0) ? track_index - 1 : track_list.length - 1;
loadTrack(track_index);
playTrack();
}
function seekTo() {
let seekto = curr_track.duration * (seek_slider.value / 100);
curr_track.currentTime = seekto;
}
function seekUpdate() {
if (!isNaN(curr_track.duration)) {
let seekPosition = curr_track.currentTime * (100 / curr_track.duration);
seek_slider.value = seekPosition;
let currentMinutes = Math.floor(curr_track.currentTime / 60);
let currentSeconds = Math.floor(curr_track.currentTime - currentMinutes * 60);
let durationMinutes = Math.floor(curr_track.duration / 60);
let durationSeconds = Math.floor(curr_track.duration - durationMinutes * 60);
if (currentSeconds < 10) currentSeconds = "0" + currentSeconds;
if (durationSeconds < 10) durationSeconds = "0" + durationSeconds;
curr_time.textContent = currentMinutes + ":" + currentSeconds;
total_duration.textContent = durationMinutes + ":" + durationSeconds;
}
}
// Event listeners
playpause_btn.addEventListener("click", playpauseTrack);
next_btn.addEventListener("click", nextTrack);
prev_btn.addEventListener("click", prevTrack);
seek_slider.addEventListener("change", seekTo);
loadTrack(track_index);
})();
</script>
No comments:
Post a Comment