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

Commit 70b0795d authored by elleo's avatar elleo

Merge commit 'refs/merge-requests/48' of git://gitorious.org/foocorp/gnu-fm into merge48

parents 0bc276cd 63d65d08
......@@ -31,6 +31,7 @@ var player_ready = false;
var playable_songs = false;
var streaming = false;
var example_tags = "e.g. guitar, violin, female vocals, piano";
var error_count = 0;
/**
* Initialises the javascript player (player.tpl must also be included on the target page)
......@@ -79,6 +80,7 @@ function playerReady() {
loadSong(0);
audio.pause();
audio.addEventListener("ended", songEnded, false);
audio.addEventListener("error", songError, false);
updateProgress();
$("#play").fadeTo("normal", 1);
$("#pause").fadeTo("normal", 1);
......@@ -100,9 +102,6 @@ function playerReady() {
*/
function play() {
audio.play();
if(!now_playing) {
nowPlaying();
}
$("#play").hide();
$("#pause").show();
$("#seekforward").fadeTo("normal", 1);
......@@ -148,6 +147,12 @@ function updateProgress() {
} else {
$("#duration").text(friendlyTime(0));
}
if(!now_playing && audio.currentTime > 0) {
error_count = 0;
nowPlaying();
}
if (!scrobbled && audio.currentTime > audio.duration / 2) {
scrobble();
}
......@@ -167,6 +172,17 @@ function songEnded() {
}
}
/**
* Called automatically when a song returns an error.
* Loads the next song after a delay or does nothing if there has been several song errors in a row.
*/
function songError() {
if (error_count < 10 ) {
error_count = error_count + 1;
setTimeout("songEnded()", 3000);
}
}
/**
* Outputs the HTML playlist
*/
......@@ -331,7 +347,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) {
}
}
......@@ -345,6 +363,24 @@ 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;
var pl = playlist.slice(-40); //only check against 40 latest tracks in playlist
for(i in pl) {
if(pl[i].artist === creator && pl[i].track === title) {
return i;
}
}
return false;
}
/**
* Plays the song previous to the current one in the playlist
*/
......
......@@ -2,7 +2,7 @@
<h3>Search</h3>
<form action='/search.php' method='get'>
<form action='{$base_url}/search.php' method='get'>
<p><input name='search_term' type='text' size="10" value='{$search_term|escape:'html':'UTF-8'}'/>
<select name='search_type'>
<option value='artist' {if $search_type == 'artist'}selected{/if}>{t}Artist{/t}</option>
......
......@@ -56,7 +56,7 @@ if (isset($user->name)) {
}
$smarty->assign('radio_session', $radio_session);
$submenu = user_menu($user, 'Radio Station');
$submenu = user_menu($user, 'Radio Stations');
$smarty->assign('submenu', $submenu);
$smarty->assign('type', $type);
$smarty->assign('headerfile', 'maxiprofile.tpl');
......
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