New Features

* Adds Refresh button for changing music
This commit is contained in:
2025-06-30 01:15:19 +05:30
parent 8929f68f75
commit 35ea31700f
3 changed files with 213 additions and 171 deletions

48
hg.css
View File

@@ -1,5 +1,5 @@
@font-face { @font-face {
font-family: 'StreamSter'; font-family: "StreamSter";
src: url(./fonts/Streamster.ttf); src: url(./fonts/Streamster.ttf);
} }
#app, #app,
@@ -14,8 +14,8 @@ body {
width: 100%; width: 100%;
padding: 0; padding: 0;
margin: 0; margin: 0;
background: #FAFAFA; background: #fafafa;
font-family: 'Helvetica Neue', arial, sans-serif; font-family: "Helvetica Neue", arial, sans-serif;
font-weight: 400; font-weight: 400;
color: #444; color: #444;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
@@ -67,10 +67,22 @@ body {
.music-player .gradient-overlay { .music-player .gradient-overlay {
/* bg-gradient: */ /* bg-gradient: */
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.6) 21%); background-image: -webkit-linear-gradient(
background-image: -moz-linear-gradient(rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.6) 21%); rgba(0, 0, 0, 0) 0%,
background-image: -o-linear-gradient(rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.6) 21%); rgba(0, 0, 0, 0.6) 21%
background-image: linear-gradient(rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.6) 21%); );
background-image: -moz-linear-gradient(
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.6) 21%
);
background-image: -o-linear-gradient(
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.6) 21%
);
background-image: linear-gradient(
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.6) 21%
);
width: 350px; width: 350px;
height: 500px; height: 500px;
position: absolute; position: absolute;
@@ -119,7 +131,7 @@ h3#track-name {
font-weight: 500; font-weight: 500;
letter-spacing: 2px; letter-spacing: 2px;
color: #e91e63; color: #e91e63;
font-family: 'StreamSter', sans-serif; font-family: "StreamSter", sans-serif;
margin-bottom: 0; margin-bottom: 0;
background: rgb(0 0 0 / 71%); background: rgb(0 0 0 / 71%);
padding: 10px; padding: 10px;
@@ -130,14 +142,14 @@ hr {
height: 3px; height: 3px;
margin: 20px auto; margin: 20px auto;
border: 0; border: 0;
background: #D0BB57; background: #d0bb57;
} }
.intro { .intro {
width: 170px; width: 170px;
margin: 0 auto; margin: 0 auto;
color: #DCE3E7; color: #dce3e7;
font-family: 'Droid Serif', serif; font-family: "Droid Serif", serif;
font-size: 13px; font-size: 13px;
font-style: italic; font-style: italic;
line-height: 18px; line-height: 18px;
@@ -161,11 +173,13 @@ dialog button {
} }
dialog::backdrop { dialog::backdrop {
background: repeating-linear-gradient(45deg, background: repeating-linear-gradient(
45deg,
rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2),
rgba(0, 0, 0, 0.2) 1px, rgba(0, 0, 0, 0.2) 1px,
rgba(0, 0, 0, 0.3) 1px, rgba(0, 0, 0, 0.3) 1px,
rgba(0, 0, 0, 0.3) 20px); rgba(0, 0, 0, 0.3) 20px
);
backdrop-filter: blur(3px); backdrop-filter: blur(3px);
} }
@@ -257,3 +271,11 @@ canvas {
position: absolute; position: absolute;
top: 0; top: 0;
} }
.refresh {
z-index: 999;
cursor: pointer;
position: relative;
float: right;
user-select: none;
}

View File

@@ -30,6 +30,7 @@
</div> </div>
<div id="app"> <div id="app">
<div class="music-player"> <div class="music-player">
<div class="no-pause refresh">🔃</div>
<div class="title-content"> <div class="title-content">
<div class="intro">Now Playing</div> <div class="intro">Now Playing</div>
<hr> <hr>

View File

@@ -6,6 +6,7 @@
const retroWaveRu = "https://retrowave.ru"; const retroWaveRu = "https://retrowave.ru";
let titleEl = document.getElementById("track-name"); let titleEl = document.getElementById("track-name");
let coverArtEl = document.getElementsByClassName("music-player")[0]; let coverArtEl = document.getElementsByClassName("music-player")[0];
let refreshBtn = document.querySelector(".refresh");
const modalEl = document.getElementById("intro-modal"); const modalEl = document.getElementById("intro-modal");
// const uploadInfoEl = document.getElementById("upload-info"); // const uploadInfoEl = document.getElementById("upload-info");
const fileUploadEl = document.getElementById("file-upload"); const fileUploadEl = document.getElementById("file-upload");
@@ -56,7 +57,7 @@
modalEl.classList.remove("open"); modalEl.classList.remove("open");
playMusic(); playMusic();
initHydra(); initHydra();
// initCodef(); initControls();
}); });
document.getElementById("history").addEventListener("click", () => { document.getElementById("history").addEventListener("click", () => {
@@ -120,16 +121,15 @@
modalEl.classList.add("open"); modalEl.classList.add("open");
} }
function getMusic() { async function getMusic() {
fetch(`https://retrowave.ru/api/v1/tracks?limit=5&cursor=${cursor}`) const res = await fetch(
.then((res) => res.json()) `https://retrowave.ru/api/v1/tracks?limit=10&cursor=${cursor}`
.then((res) => { ).then((res) => res.json());
const { const {
body: { tracks, cursor: currentCursor }, body: { tracks, cursor: currentCursor },
} = res; } = res;
cursor = currentCursor; cursor = currentCursor;
currentTracks = tracks; currentTracks = tracks;
});
} }
function initPlayer() { } function initPlayer() { }
@@ -142,11 +142,7 @@
src: [fullTrack], src: [fullTrack],
html5: true, html5: true,
onend: function () { onend: function () {
currentTracks.shift(); playNextTrack();
if (currentTracks.length <= 3) {
getMusic();
}
playMusic();
}, },
}); });
setVolume(); setVolume();
@@ -233,6 +229,29 @@ https://retrowave.ru/${musicData.streamUrl}
document.body.removeChild(element); document.body.removeChild(element);
} }
function playNextTrack() {
currentTracks.shift();
if (currentTracks.length <= 3) {
getMusic();
}
playMusic();
}
function resetHowler(destroy = false) {
howlerInstance.stop();
if (destroy) {
howlerInstance.unload();
howlerInstance = null;
}
}
function initControls() {
refreshBtn.addEventListener("click", () => {
resetHowler();
playNextTrack();
});
}
// function initCodef() { // function initCodef() {
// const width = window.innerWidth; // const width = window.innerWidth;
// const height = window.innerHeight; // const height = window.innerHeight;