diff --git a/README.md b/README.md index fe06971..d49cbd3 100644 --- a/README.md +++ b/README.md @@ -94,9 +94,7 @@ To change the number of history items displayed, edit `js/script.js` and modify ## 🌐 API Integration -This player uses [RadioAPI.me](https://radioapi.me) for metadata. Get your API endpoint from their service. - -For lyrics functionality, get a Vagalume API key from [Vagalume API](https://api.vagalume.com.br/docs/). +This player uses [RadioAPI.me](https://radioapi.me) for metadata and its lyrics. Get your API endpoint from their service. ## 🐛 Troubleshooting diff --git a/css/style.css b/css/style.css index 85c6b1b..23d4ea2 100644 --- a/css/style.css +++ b/css/style.css @@ -333,7 +333,7 @@ main { #currentCoverArt { width: 100%; height: 100%; - background: url("../img/cover.png") no-repeat center; + background: url("../img/cover.jpeg") no-repeat center; background-size: cover; transition: background-image 1s ease; } @@ -588,7 +588,7 @@ input[type="range"]::-moz-range-thumb { .cover-historic { width: 80px; height: 80px; - background: url("../img/cover.png") no-repeat center; + background: url("../img/cover.jpeg") no-repeat center; background-size: cover; border-radius: 10px; flex-shrink: 0; diff --git a/img/.DS_Store b/img/.DS_Store index 86f8478..db68dce 100644 Binary files a/img/.DS_Store and b/img/.DS_Store differ diff --git a/img/cover.jpeg b/img/cover.jpeg new file mode 100644 index 0000000..988c673 Binary files /dev/null and b/img/cover.jpeg differ diff --git a/img/cover.png b/img/cover.png deleted file mode 100644 index cce3823..0000000 Binary files a/img/cover.png and /dev/null differ diff --git a/js/script.js b/js/script.js index 603ca44..ceeff01 100644 --- a/js/script.js +++ b/js/script.js @@ -1,13 +1,10 @@ -const RADIO_NAME = "Game! Radio" +const RADIO_NAME = "Afrofusion Rap" // Change Stream URL Here, Supports, ICECAST, ZENO, SHOUTCAST, RADIOJAR ETC.... DOES NOT SUPPORT HLS -const URL_STREAMING = "https://play.streamafrica.net/gameradio" +const URL_STREAMING = "https://play.streamafrica.net/afrofusionrap" // NEW UNIFIED API ENDPOINT -const API_URL = "https://prod-api.radioapi.me/metadata/51a50466-49b7-444c-9a4a-4caf0a1aff64" - -// Visit https://api.vagalume.com.br/docs/ to get your API key -const API_KEY = "18fe07917957c289983464588aabddfb" +const API_URL = "https://prod-api.radioapi.me/metadata/92f09a6d-37f1-4c10-bf2a-018bf03136fc" // Loading state management let isInitialLoad = true @@ -19,8 +16,10 @@ const currentSongData = { artist: "", } + window.onload = () => { + var page = new Page() page.changeTitlePage() page.setVolume() @@ -34,7 +33,6 @@ window.onload = () => { // Initial data fetch getStreamingData() - // Interval to get streaming data in milliseconds setInterval(() => { getStreamingData() @@ -287,72 +285,48 @@ function Page() { } } - this.refreshLyric = (currentSong, currentArtist) => { + this.refreshLyric = (lyrics) => { // Show lyrics loading showLyricsLoading() - var xhttp = new XMLHttpRequest() - xhttp.onreadystatechange = function () { - // Hide lyrics loading + var openLyric = document.getElementsByClassName("lyrics")[0] + + // Hide lyrics loading + setTimeout(() => { hideLyricsLoading() + }, 500) - if (this.readyState === 4 && this.status === 200) { - var data = JSON.parse(this.responseText) + if (lyrics && lyrics.trim() !== "") { + // Remove skeleton loading from modal + const lyricsLoading = document.querySelector(".lyrics-loading") + if (lyricsLoading) lyricsLoading.style.display = "none" - var openLyric = document.getElementsByClassName("lyrics")[0] + const lyricElement = document.getElementById("lyric") + if (lyricElement) { + lyricElement.innerHTML = lyrics.replace(/\n/g, "
") + } - if (data.type === "exact" || data.type === "aprox") { - var lyric = data.mus[0].text + if (openLyric) { + openLyric.style.opacity = "1" + openLyric.setAttribute("data-toggle", "modal") + } + } else { + if (openLyric) { + openLyric.style.opacity = "0.3" + openLyric.removeAttribute("data-toggle") + } - // Remove skeleton loading from modal - const lyricsLoading = document.querySelector(".lyrics-loading") - if (lyricsLoading) lyricsLoading.style.display = "none" + var modalLyric = document.getElementById("modalLyrics") + if (modalLyric) { + modalLyric.style.display = "none" + modalLyric.setAttribute("aria-hidden", "true") + } - const lyricElement = document.getElementById("lyric") - if (lyricElement) { - lyricElement.innerHTML = lyric.replace(/\n/g, "
") - } - - if (openLyric) { - openLyric.style.opacity = "1" - openLyric.setAttribute("data-toggle", "modal") - } - } else { - if (openLyric) { - openLyric.style.opacity = "0.3" - openLyric.removeAttribute("data-toggle") - } - - var modalLyric = document.getElementById("modalLyrics") - if (modalLyric) { - modalLyric.style.display = "none" - modalLyric.setAttribute("aria-hidden", "true") - } - - const backdrop = document.getElementsByClassName("modal-backdrop")[0] - if (backdrop) { - backdrop.remove() - } - } - } else { - var lyricsElement = document.getElementsByClassName("lyrics")[0] - if (lyricsElement) { - lyricsElement.style.opacity = "0.3" - lyricsElement.removeAttribute("data-toggle") - } + const backdrop = document.getElementsByClassName("modal-backdrop")[0] + if (backdrop) { + backdrop.remove() } } - xhttp.open( - "GET", - "https://api.vagalume.com.br/search.php?apikey=" + - API_KEY + - "&art=" + - currentArtist + - "&mus=" + - currentSong.toLowerCase(), - true, - ) - xhttp.send() } } @@ -528,7 +502,7 @@ function getStreamingData() { } // Update lyrics - page.refreshLyric(song, artist) + page.refreshLyric(data.lyrics || "") // Update history if available if (data.history && data.history.length > 0) { @@ -717,16 +691,16 @@ function decimalToInt(vol) { function initializeHistoryItems() { const historyContainer = document.getElementById("historicSong") const HISTORY_ITEMS_COUNT = 5 - + if (historyContainer) { // Clear any existing items historyContainer.innerHTML = "" - + // Generate history items for (let i = 0; i < HISTORY_ITEMS_COUNT; i++) { const historyItem = document.createElement("article") historyItem.className = "history-item" - + historyItem.innerHTML = `
@@ -740,7 +714,7 @@ function initializeHistoryItems() {
` - + historyContainer.appendChild(historyItem) } }