Commit 29539103 authored by Jonas Haraldsson's avatar Jonas Haraldsson

New songError function

New songError function that gets called when a song cant be played,
songError adds the error to variable error_count and calls the songEnded function
after a delay. If there has been 10 errors in a row the function does
nothing and the player stops playback.
parent 8f9c2503
......@@ -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 song_errors = 0;
/**
* Initialises the javascript player (player.tpl must also be included on the target page)
......@@ -79,7 +80,7 @@ function playerReady() {
loadSong(0);
audio.pause();
audio.addEventListener("ended", songEnded, false);
audio.addEventListener("error", songEnded, false);
audio.addEventListener("error", songError, false);
updateProgress();
$("#play").fadeTo("normal", 1);
$("#pause").fadeTo("normal", 1);
......@@ -148,6 +149,7 @@ function updateProgress() {
}
if(!now_playing && audio.currentTime > 0) {
song_errors = 0;
nowPlaying();
}
......@@ -170,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 (song_errors < 10 ) {
song_errors = song_errors + 1;
setTimeout("songEnded()", 3000);
}
}
/**
* Outputs the HTML 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