mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2025-01-05 12:21:59 -05:00
sounds track playing state
This commit is contained in:
parent
7f741a509c
commit
088efdeb0e
1 changed files with 4 additions and 0 deletions
|
@ -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();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue