mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Use promises to yield
This commit is contained in:
parent
46f885fc03
commit
2348d55f14
1 changed files with 14 additions and 6 deletions
|
@ -204,11 +204,11 @@ class Scratch3SoundBlocks {
|
|||
}
|
||||
|
||||
setEffect (args, util) {
|
||||
this._updateEffect(args, util, false);
|
||||
return this._updateEffect(args, util, false);
|
||||
}
|
||||
|
||||
changeEffect (args, util) {
|
||||
this._updateEffect(args, util, true);
|
||||
return this._updateEffect(args, util, true);
|
||||
}
|
||||
|
||||
_updateEffect (args, util, change) {
|
||||
|
@ -229,7 +229,11 @@ class Scratch3SoundBlocks {
|
|||
|
||||
if (util.target.audioPlayer === null) return;
|
||||
util.target.audioPlayer.setEffect(effect, soundState.effects[effect]);
|
||||
this.runtime.requestRedraw();
|
||||
|
||||
// Yield until the next tick.
|
||||
return new Promise(resolve => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
_syncEffectsForTarget (target) {
|
||||
|
@ -265,12 +269,12 @@ class Scratch3SoundBlocks {
|
|||
|
||||
setVolume (args, util) {
|
||||
const volume = Cast.toNumber(args.VOLUME);
|
||||
this._updateVolume(volume, util);
|
||||
return this._updateVolume(volume, util);
|
||||
}
|
||||
|
||||
changeVolume (args, util) {
|
||||
const volume = Cast.toNumber(args.VOLUME) + util.target.volume;
|
||||
this._updateVolume(volume, util);
|
||||
return this._updateVolume(volume, util);
|
||||
}
|
||||
|
||||
_updateVolume (volume, util) {
|
||||
|
@ -278,7 +282,11 @@ class Scratch3SoundBlocks {
|
|||
util.target.volume = volume;
|
||||
if (util.target.audioPlayer === null) return;
|
||||
util.target.audioPlayer.setVolume(util.target.volume);
|
||||
this.runtime.requestRedraw();
|
||||
|
||||
// Yield until the next tick.
|
||||
return new Promise(resolve => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
getVolume (args, util) {
|
||||
|
|
Loading…
Reference in a new issue