Skip to content

Commit

Permalink
katspaugh#379 avoid race condition caused by requestAnimationFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Apr 11, 2015
1 parent 7acbad3 commit 786ac62
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/wavesurfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,11 @@ var WaveSurfer = {
});

this.backend.on('audioprocess', function (time) {
my.drawer.progress(my.backend.getPlayedPercents());
my.fireEvent('audioprocess', time);
});
},

restartAnimationLoop: function () {
var my = this;
var requestFrame = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame;
var frame = function () {
if (!my.backend.isPaused()) {
my.drawer.progress(my.backend.getPlayedPercents());
requestFrame(frame);
}
};
frame();
},

getDuration: function () {
return this.backend.getDuration();
},
Expand All @@ -146,7 +134,6 @@ var WaveSurfer = {

play: function (start, end) {
this.backend.play(start, end);
this.restartAnimationLoop();
this.fireEvent('play');
},

Expand Down

0 comments on commit 786ac62

Please sign in to comment.