sounds track playing state

This commit is contained in:
Eric Rosenbaum 2017-01-30 18:13:18 -05:00
parent 7f741a509c
commit 088efdeb0e

View file

@ -27,6 +27,7 @@ SoundPlayer.prototype.stop = function () {
if (this.bufferSource) { if (this.bufferSource) {
this.bufferSource.stop(); this.bufferSource.stop();
} }
this.isPlaying = false;
}; };
SoundPlayer.prototype.start = function () { SoundPlayer.prototype.start = function () {
@ -39,12 +40,15 @@ SoundPlayer.prototype.start = function () {
this.bufferSource.playbackRate.value = this.playbackRate; this.bufferSource.playbackRate.value = this.playbackRate;
this.bufferSource.connect(this.outputNode); this.bufferSource.connect(this.outputNode);
this.bufferSource.start(); this.bufferSource.start();
this.isPlaying = true;
}; };
SoundPlayer.prototype.finished = function () { SoundPlayer.prototype.finished = function () {
var storedContext = this; var storedContext = this;
return new Promise(function (resolve) { return new Promise(function (resolve) {
storedContext.bufferSource.onended = function () { storedContext.bufferSource.onended = function () {
this.isPlaying = false;
resolve(); resolve();
}; };
}); });