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

View file

@ -1497,21 +1497,21 @@ const webamp = new Webamp({
"artist": "OutKast",
"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": {
"artist": "OutKast",
"title": "Spaghetti Junction"
},
"url": "https://8.prigoana.lol/OutKast - Spaghetti Junction.flac"
"url": "https://8.prigoana.lol/Outkast - Spaghetti Junction.flac"
},
{
"metaData": {
"artist": "OutKast with Khujo Goodie",
"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": {
@ -1623,14 +1623,14 @@ const webamp = new Webamp({
"artist": "OutKast",
"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": {
"artist": "OutKast",
"title": "Xplosion"
},
"url": "https://9.prigoana.lol/OutKast - Xplosion.flac"
"url": "https://9.prigoana.lol/OutKast-%20Xplosion.flac"
},
{
"metaData": {