This commit is contained in:
EduardSkibidiEdger 2024-12-01 22:04:30 +02:00
parent 791cd5254c
commit 630e63588e
2 changed files with 28 additions and 48 deletions

View file

@ -114,7 +114,6 @@
<script src="https://unpkg.com/butterchurn/lib/butterchurn.min.js"></script> <script src="https://unpkg.com/butterchurn/lib/butterchurn.min.js"></script>
<script src="https://unpkg.com/butterchurn-presets/lib/butterchurnPresets.min.js"></script> <script src="https://unpkg.com/butterchurn-presets/lib/butterchurnPresets.min.js"></script>
<script src="./index.js"></script> <script src="./index.js"></script>
<script> <script>
let username = localStorage.getItem('lastfmUsername') || 'yetiuard'; let username = localStorage.getItem('lastfmUsername') || 'yetiuard';
const url = `https://lastfm-last-played.biancarosa.com.br/${username}/latest-song`; const url = `https://lastfm-last-played.biancarosa.com.br/${username}/latest-song`;
@ -187,41 +186,22 @@
document.getElementById('favicon').href = newIcon; document.getElementById('favicon').href = newIcon;
}); });
}); });
</script>
<script>
let currentSong = {
title: '',
artist: ''
};
// Update currentSong with the track details every time the track changes // New onTrackDidChange functionality
webamp.onTrackDidChange((trackInfo) => { const unsubscribe = webamp.onTrackDidChange((trackInfo) => {
if (trackInfo) { if (trackInfo && trackInfo.metaData) {
currentSong = { const { title = "Unknown Title", artist = "Unknown Artist" } = trackInfo.metaData;
title: trackInfo.metaData.title || '', console.log("New track playing:", { title, artist });
artist: trackInfo.metaData.artist || '' } else if (trackInfo) {
}; console.log("New track URL:", trackInfo.url);
console.log('Currently playing:', currentSong);
} else { } else {
// If no track is playing, set the song to empty values console.log("No track is currently playing.");
currentSong = {
title: '',
artist: ''
};
console.log('No track is currently playing');
} }
}); });
// You can check the current song at any time // Example: Unsubscribe when no longer needed
function getCurrentSong() { // unsubscribe();
return currentSong;
}
// Example of how you can get the current song manually:
setInterval(() => {
console.log('Current Song:', getCurrentSong());
}, 5000); // Logs the current song every 5 seconds
</script> </script>
</body> </body>
</html> </html>

View file

@ -1497,21 +1497,21 @@ const webamp = new Webamp({
"artist": "OutKast", "artist": "OutKast",
"title": "So Fresh, So Clean" "title": "So Fresh, So Clean"
}, },
"url": "https://8.prigoana.lol/OutKast - So Fresh, So Clean.flac" "url": "https://8.prigoana.lol/Outkast - So Fresh, So Clean.flac"
}, },
{ {
"metaData": { "metaData": {
"artist": "OutKast", "artist": "OutKast",
"title": "Spaghetti Junction" "title": "Spaghetti Junction"
}, },
"url": "https://8.prigoana.lol/OutKast - Spaghetti Junction.flac" "url": "https://8.prigoana.lol/Outkast - Spaghetti Junction.flac"
}, },
{ {
"metaData": { "metaData": {
"artist": "OutKast with Khujo Goodie", "artist": "OutKast with Khujo Goodie",
"title": "Gasoline Dreams" "title": "Gasoline Dreams"
}, },
"url": "https://8.prigoana.lol/OutKast with Khujo Goodie - Gasoline Dreams.flac" "url": "https://8.prigoana.lol/Outkast with Khujo Goodie - Gasoline Dreams.flac"
}, },
{ {
"metaData": { "metaData": {
@ -1623,14 +1623,14 @@ const webamp = new Webamp({
"artist": "OutKast", "artist": "OutKast",
"title": "B.O.B. (Bombs Over Baghdad)" "title": "B.O.B. (Bombs Over Baghdad)"
}, },
"url": "https://9.prigoana.lol/OutKast - B.O.B. (Bombs Over Baghdad).flac" "url": "https://9.prigoana.lol/Outkast - B.O.B. (Bombs Over Baghdad).flac"
}, },
{ {
"metaData": { "metaData": {
"artist": "OutKast", "artist": "OutKast",
"title": "Xplosion" "title": "Xplosion"
}, },
"url": "https://9.prigoana.lol/OutKast - Xplosion.flac" "url": "https://9.prigoana.lol/OutKast-%20Xplosion.flac"
}, },
{ {
"metaData": { "metaData": {