diff --git a/extensions/Lily/SoundExpanded.js b/extensions/Lily/SoundExpanded.js index c8fb17e0da..0b1a3ab0b9 100644 --- a/extensions/Lily/SoundExpanded.js +++ b/extensions/Lily/SoundExpanded.js @@ -26,9 +26,9 @@ name: "Sound Expanded", blocks: [ { - opcode: 'startSoundOnLoop', + opcode: 'startLooping', blockType: Scratch.BlockType.COMMAND, - text: 'start sound [SOUND] on loop', + text: 'start looping [SOUND]', arguments: { SOUND: { type: Scratch.ArgumentType.SOUND @@ -40,22 +40,9 @@ } }, { - opcode: 'stopSound', - blockType: Scratch.BlockType.COMMAND, - text: 'stop sound [SOUND]', - arguments: { - SOUND: { - type: Scratch.ArgumentType.SOUND - } - } - }, - - '---', - - { - opcode: 'pauseSounds', + opcode: 'stopLooping', blockType: Scratch.BlockType.COMMAND, - text: 'pause all sounds', + text: 'end looping [SOUND]', arguments: { SOUND: { type: Scratch.ArgumentType.SOUND @@ -63,9 +50,9 @@ } }, { - opcode: 'resumeSounds', - blockType: Scratch.BlockType.COMMAND, - text: 'resume all sounds', + opcode: 'isLooping', + blockType: Scratch.BlockType.BOOLEAN, + text: '[SOUND] is looping?', arguments: { SOUND: { type: Scratch.ArgumentType.SOUND @@ -76,9 +63,9 @@ '---', { - opcode: 'startLooping', + opcode: 'stopSound', blockType: Scratch.BlockType.COMMAND, - text: 'begin looping [SOUND]', + text: 'stop sound [SOUND]', arguments: { SOUND: { type: Scratch.ArgumentType.SOUND @@ -86,9 +73,9 @@ } }, { - opcode: 'stopLooping', + opcode: 'pauseSounds', blockType: Scratch.BlockType.COMMAND, - text: 'end looping [SOUND]', + text: 'pause all sounds', arguments: { SOUND: { type: Scratch.ArgumentType.SOUND @@ -96,9 +83,9 @@ } }, { - opcode: 'isLooping', - blockType: Scratch.BlockType.BOOLEAN, - text: '[SOUND] is looping?', + opcode: 'resumeSounds', + blockType: Scratch.BlockType.COMMAND, + text: 'resume all sounds', arguments: { SOUND: { type: Scratch.ArgumentType.SOUND @@ -193,23 +180,48 @@ }; } - startSoundOnLoop(args, util) { + startLooping(args, util) { const index = this._getSoundIndex(args.SOUND, util); if (index < 0) return 0; const target = util.target; - const sprite = target.sprite; - const duration = args.START; + const sprite = util.target.sprite; const soundId = sprite.sounds[index].soundId; - soundCategory._addWaitingSound(target.id, soundId); - sprite.soundBank.playSound(util.target, soundId); - const soundPlayer = sprite.soundBank.soundPlayers[soundId]; + if (!soundPlayer.isPlaying) { + soundCategory._addWaitingSound(target.id, soundId); + sprite.soundBank.playSound(util.target, soundId); + } + if (!soundPlayer.outputNode) return; soundPlayer.outputNode.loop = true; } + stopLooping(args, util) { + const index = this._getSoundIndex(args.SOUND, util); + if (index < 0) return false; + const sprite = util.target.sprite; + + const soundId = sprite.sounds[index].soundId; + const soundPlayer = sprite.soundBank.soundPlayers[soundId]; + + if (!soundPlayer.outputNode) return; + soundPlayer.outputNode.loop = false; + } + + isLooping(args, util) { + const index = this._getSoundIndex(args.SOUND, util); + if (index < 0) return false; + const sprite = util.target.sprite; + + const soundId = sprite.sounds[index].soundId; + const soundPlayer = sprite.soundBank.soundPlayers[soundId]; + + if (!soundPlayer.outputNode) return false; + return soundPlayer.outputNode.loop; + } + stopSound(args, util) { const index = this._getSoundIndex(args.SOUND, util); if (index < 0) return 0; @@ -242,42 +254,6 @@ } } - startLooping(args, util) { - const index = this._getSoundIndex(args.SOUND, util); - if (index < 0) return false; - const sprite = util.target.sprite; - - const soundId = sprite.sounds[index].soundId; - const soundPlayer = sprite.soundBank.soundPlayers[soundId]; - - if (!soundPlayer.outputNode) return; - soundPlayer.outputNode.loop = true; - } - - stopLooping(args, util) { - const index = this._getSoundIndex(args.SOUND, util); - if (index < 0) return false; - const sprite = util.target.sprite; - - const soundId = sprite.sounds[index].soundId; - const soundPlayer = sprite.soundBank.soundPlayers[soundId]; - - if (!soundPlayer.outputNode) return; - soundPlayer.outputNode.loop = false; - } - - isLooping(args, util) { - const index = this._getSoundIndex(args.SOUND, util); - if (index < 0) return false; - const sprite = util.target.sprite; - - const soundId = sprite.sounds[index].soundId; - const soundPlayer = sprite.soundBank.soundPlayers[soundId]; - - if (!soundPlayer.outputNode) return false; - return soundPlayer.outputNode.loop; - } - isSoundPlaying(args, util) { const index = this._getSoundIndex(args.SOUND, util); if (index < 0) return false;