Skip to content

Instantly share code, notes, and snippets.

@sybarite
Created November 13, 2015 11:24
Show Gist options
  • Save sybarite/8ba77b9790fd036fde6f to your computer and use it in GitHub Desktop.
Save sybarite/8ba77b9790fd036fde6f to your computer and use it in GitHub Desktop.
var old_timestamp = Math.floor(Date.now()/1000);
var old_timestamp2 = -1;
selected_theme[selected_key+"Loop"] = function() {
var pause;
var seconds = parseInt(getSeconds(selected_voice.time));
var timestamp = selected_theme["timestampvoice" + selected_voice.aftype] + seconds;
if (seconds == 0){
if (timestamp > old_timestamp2 && old_timestamp2 != 0) {
pause = 0;
old_timestamp2 = timestamp;
} else {
pause = 1;
old_timestamp2 = timestamp;
}
} else if ((timestamp > old_timestamp) && (Math.floor(Date.now()/1000) >= timestamp)) {
old_timestamp = timestamp;
pause = 0;
} else {
pause = 1;
}
if (Math.floor(Date.now()/1000) >= timestamp) {
if (pause == 0) {
// play the audio
} else {
// execute selected_theme[selected_key+"Loop"]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment