mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2025-01-03 11:35:49 -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) {
|
||||
this.bufferSource.stop();
|
||||
}
|
||||
this.isPlaying = false;
|
||||
};
|
||||
|
||||
SoundPlayer.prototype.start = function () {
|
||||
|
@ -39,12 +40,15 @@ SoundPlayer.prototype.start = function () {
|
|||
this.bufferSource.playbackRate.value = this.playbackRate;
|
||||
this.bufferSource.connect(this.outputNode);
|
||||
this.bufferSource.start();
|
||||
|
||||
this.isPlaying = true;
|
||||
};
|
||||
|
||||
SoundPlayer.prototype.finished = function () {
|
||||
var storedContext = this;
|
||||
return new Promise(function (resolve) {
|
||||
storedContext.bufferSource.onended = function () {
|
||||
this.isPlaying = false;
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue