We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit b3c23d8b authored by Jonas Haraldsson's avatar Jonas Haraldsson

no more dupes in playlist

Checks if a track is already in playlist,
if it is we dont add it again
parent 8d5f30fa
......@@ -332,7 +332,9 @@ function getRadioPlaylist() {
album = tracks[i].getElementsByTagName("album")[0].childNodes[0].nodeValue;
url = tracks[i].getElementsByTagName("location")[0].childNodes[0].nodeValue;
trackpage_url = tracks[i].getElementsByTagName("trackpage")[0].childNodes[0].nodeValue;
playlist.push({"artist" : artist, "album" : album, "track" : title, "url" : url, "trackpage" : trackpage_url});
if(checkDupe(playlist, artist, title) === false) {
playlist.push({"artist" : artist, "album" : album, "track" : title, "url" : url, "trackpage" : trackpage_url});
}
} catch(err) {
}
}
......@@ -346,6 +348,23 @@ function getRadioPlaylist() {
}, "text");
}
/**
* Check if track is already in playlist
*
* @param array Playlist array
* @param creator Track creator (artist name)
* @param title Track title
*/
function checkDupe(playlist, creator, title) {
var i;
for(i in playlist) {
if(playlist[i].artist === creator && playlist[i].track === title) {
return i;
}
}
return false;
}
/**
* Plays the song previous to the current one in the playlist
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment