Created
October 27, 2014 21:31
-
-
Save meandavejustice/20cf22ebab660ba49818 to your computer and use it in GitHub Desktop.
rendering currentTime after multiple pauses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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