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

332
hg.css
View File

@@ -1,86 +1,98 @@
@font-face { @font-face {
font-family: 'StreamSter'; font-family: "StreamSter";
src: url(./fonts/Streamster.ttf); src: url(./fonts/Streamster.ttf);
} }
#app, #app,
body, body,
html { html {
height: 100%; height: 100%;
} }
html, html,
body { body {
height: 100%; height: 100%;
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;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
body { body {
background: #f5b7f0; background: #f5b7f0;
background-image: url("./images/rainbowprism.gif"); background-image: url("./images/rainbowprism.gif");
} }
#app { #app {
height: 100%; height: 100%;
} }
* { * {
box-sizing: border-box; box-sizing: border-box;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
.music-player { .music-player {
width: 350px; width: 350px;
height: 500px; height: 500px;
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 50%; left: 50%;
margin: -250px 0 0 -175px; margin: -250px 0 0 -175px;
overflow: hidden; overflow: hidden;
border-radius: 10px; border-radius: 10px;
box-shadow: 3px 3px 20px rgba(0, 0, 0, 0.5); box-shadow: 3px 3px 20px rgba(0, 0, 0, 0.5);
text-align: center; text-align: center;
background-position: 50% 50%; background-position: 50% 50%;
background-repeat: no-repeat; background-repeat: no-repeat;
z-index: 999; z-index: 999;
} }
.music-player .color-overlay { .music-player .color-overlay {
/* Rectangle 11: */ /* Rectangle 11: */
background: rgba(84, 104, 110, 0.4); background: rgba(84, 104, 110, 0.4);
width: 350px; width: 350px;
height: 500px; height: 500px;
position: absolute; position: absolute;
z-index: 10; z-index: 10;
top: 0; top: 0;
left: 0; left: 0;
transition: background 0.3s cubic-bezier(0.33, 0.66, 0.66, 1); transition: background 0.3s cubic-bezier(0.33, 0.66, 0.66, 1);
} }
.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%); );
width: 350px; background-image: -moz-linear-gradient(
height: 500px; rgba(0, 0, 0, 0) 0%,
position: absolute; rgba(0, 0, 0, 0.6) 21%
top: 350px; );
left: 0; background-image: -o-linear-gradient(
z-index: 15; 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;
height: 500px;
position: absolute;
top: 350px;
left: 0;
z-index: 15;
} }
.player-controls { .player-controls {
/* width: 100%; /* width: 100%;
position: absolute; position: absolute;
bottom: 100px; bottom: 100px;
left: 0; left: 0;
@@ -96,164 +108,174 @@ body {
} }
.music-player:hover .player-controls { .music-player:hover .player-controls {
opacity: 1; opacity: 1;
bottom: 120px; bottom: 120px;
} }
.music-player:hover .color-overlay { .music-player:hover .color-overlay {
background: rgba(84, 104, 110, 0.8); background: rgba(84, 104, 110, 0.8);
} }
.title-content { .title-content {
text-align: center; text-align: center;
margin: 130px 0 0 0; margin: 130px 0 0 0;
position: absolute; position: absolute;
z-index: 20; z-index: 20;
width: 100%; width: 100%;
top: 0; top: 0;
left: 0; left: 0;
} }
h3#track-name { h3#track-name {
font-size: 26px; font-size: 26px;
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;
} }
hr { hr {
width: 50px; width: 50px;
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;
} }
dialog { dialog {
text-align: center; text-align: center;
padding: 50px; padding: 50px;
z-index: 999; z-index: 999;
border: 1px solid #000000; border: 1px solid #000000;
margin-left: 15px; margin-left: 15px;
width: 50%; width: 50%;
background: #000000; background: #000000;
color: #ffffff; color: #ffffff;
} }
dialog button { dialog button {
background: #ffffff; background: #ffffff;
border: none; border: none;
padding: 3px; padding: 3px;
} }
dialog::backdrop { dialog::backdrop {
background: repeating-linear-gradient(45deg, background: repeating-linear-gradient(
rgba(0, 0, 0, 0.2), 45deg,
rgba(0, 0, 0, 0.2) 1px, rgba(0, 0, 0, 0.2),
rgba(0, 0, 0, 0.3) 1px, rgba(0, 0, 0, 0.2) 1px,
rgba(0, 0, 0, 0.3) 20px); rgba(0, 0, 0, 0.3) 1px,
backdrop-filter: blur(3px); rgba(0, 0, 0, 0.3) 20px
);
backdrop-filter: blur(3px);
} }
.modal { .modal {
position: fixed; position: fixed;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
opacity: 0; opacity: 0;
visibility: hidden; visibility: hidden;
transition: all 0.3s ease; transition: all 0.3s ease;
top: 0; top: 0;
left: 0; left: 0;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
z-index: 9999; z-index: 9999;
} }
.modal.open { .modal.open {
visibility: visible; visibility: visible;
opacity: 1; opacity: 1;
transition-delay: 0s; transition-delay: 0s;
} }
.modal-bg { .modal-bg {
position: absolute; position: absolute;
background: teal; background: teal;
background-image: url(./images/comp009.jpg); background-image: url(./images/comp009.jpg);
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.modal-container { .modal-container {
border-radius: 10px; border-radius: 10px;
background: #fff; background: #fff;
position: relative; position: relative;
padding: 30px; padding: 30px;
} }
.modal-close { .modal-close {
position: absolute; position: absolute;
right: 15px; right: 15px;
top: 15px; top: 15px;
outline: none; outline: none;
appearance: none; appearance: none;
color: red; color: red;
background: none; background: none;
border: 0px; border: 0px;
font-weight: bold; font-weight: bold;
cursor: pointer; cursor: pointer;
} }
.text-center { .text-center {
text-align: center; text-align: center;
} }
.mt-5 { .mt-5 {
margin-top: 10px; margin-top: 10px;
} }
#file-upload { #file-upload {
display: none; display: none;
} }
.controls { .controls {
font-style: italic; font-style: italic;
font-size: larger; font-size: larger;
} }
.footer { .footer {
position: absolute; position: absolute;
bottom: 0px; bottom: 0px;
width: 350px; width: 350px;
display: flex; display: flex;
color: #ffffff; color: #ffffff;
z-index: 999; z-index: 999;
justify-content: center; justify-content: center;
} }
.footer .footer-items { .footer .footer-items {
text-decoration: none; text-decoration: none;
cursor: pointer; cursor: pointer;
padding-left: 10px; padding-left: 10px;
color: #ffffff; color: #ffffff;
justify-content: center; justify-content: center;
} }
canvas { 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;