Skip to content

Instantly share code, notes, and snippets.

@meandavejustice
Created October 27, 2014 21:31
Show Gist options
  • Select an option

  • Save meandavejustice/20cf22ebab660ba49818 to your computer and use it in GitHub Desktop.

Select an option

Save meandavejustice/20cf22ebab660ba49818 to your computer and use it in GitHub Desktop.
rendering currentTime after multiple pauses
function triggerPlaying() {
if (!playing) {
return;
}
var cur, x;
var dur = as.buffer.duration;
var diff = 0;
var actualCurrentTime = ac.currentTime - firstPlay;
if (lastPause > 0) {
diff = lastPlay - lastPause;
actualCurrentTime = actualCurrentTime - diff;
}
cur = (actualCurrentTime % 60) * 10;
x = ((cur / dur) * 10).toFixed(3);
waveProgress.style.width = x+"%";
playCursor.style.left = x+"%";
currentTimeBox.textContent = formatTime(ac.currentTime - lastPlay);
remaining.textContent = formatTime((dur - lastPlay) - (ac.currentTime - lastPlay));
if (parseInt(x) > 100) {
playing = !playing;
return;
}
webkitRequestAnimationFrame(triggerPlaying);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment