Mercurial > hg > webaudioevaluationtool
comparison interfaces/timeline.js @ 2890:29c081e03e6b
Use requestAnimationFrame for timeline
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Tue, 27 Jun 2017 21:45:10 +0100 |
parents | 64a5603831e2 |
children | 1620cbee9111 |
comparison
equal
deleted
inserted
replaced
2889:cd1cd3358544 | 2890:29c081e03e6b |
---|---|
439 progress = progress.substr(0, 5); | 439 progress = progress.substr(0, 5); |
440 this.playButton.DOM.textContent = "Loading: " + progress + '%'; | 440 this.playButton.DOM.textContent = "Loading: " + progress + '%'; |
441 }; | 441 }; |
442 this.startPlayback = function () { | 442 this.startPlayback = function () { |
443 // Called when playback has begun | 443 // Called when playback has begun |
444 canvasIntervalID = window.setInterval(this.canvas.drawTicker.bind(this.canvas), 100); | 444 var animate = function () { |
445 this.canvas.drawTicker.call(this.canvas); | |
446 if (this.playButton.DOM.textContent == "Stop") { | |
447 window.requestAnimationFrame(animate); | |
448 } | |
449 }.bind(this); | |
445 this.playButton.DOM.textContent = "Stop"; | 450 this.playButton.DOM.textContent = "Stop"; |
446 interfaceContext.commentBoxes.highlightById(audioObject.id); | 451 interfaceContext.commentBoxes.highlightById(audioObject.id); |
452 canvasIntervalID = window.requestAnimationFrame(animate); | |
447 }; | 453 }; |
448 this.stopPlayback = function () { | 454 this.stopPlayback = function () { |
449 // Called when playback has stopped. This gets called even if playback never started! | 455 // Called when playback has stopped. This gets called even if playback never started! |
450 window.clearInterval(canvasIntervalID); | 456 window.clearInterval(canvasIntervalID); |
451 this.canvas.clearCanvas(this.canvas.layer2); | 457 this.canvas.clearCanvas(this.canvas.layer2); |