Skip to content

Commit

Permalink
Update SoundExpanded.js
Browse files Browse the repository at this point in the history
  • Loading branch information
LilyMakesThings authored Aug 14, 2023
1 parent 419e9d7 commit 3cb8008
Showing 1 changed file with 45 additions and 69 deletions.
114 changes: 45 additions & 69 deletions extensions/Lily/SoundExpanded.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,32 +40,19 @@
}
},
{
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
}
}
},
{
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
Expand All @@ -76,29 +63,29 @@
'---',

{
opcode: 'startLooping',
opcode: 'stopSound',
blockType: Scratch.BlockType.COMMAND,
text: 'begin looping [SOUND]',
text: 'stop sound [SOUND]',
arguments: {
SOUND: {
type: Scratch.ArgumentType.SOUND
}
}
},
{
opcode: 'stopLooping',
opcode: 'pauseSounds',
blockType: Scratch.BlockType.COMMAND,
text: 'end looping [SOUND]',
text: 'pause all sounds',
arguments: {
SOUND: {
type: Scratch.ArgumentType.SOUND
}
}
},
{
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
Expand Down Expand Up @@ -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);

Check warning on line 194 in extensions/Lily/SoundExpanded.js

View workflow job for this annotation

GitHub Actions / build

Trailing spaces not allowed
}

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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3cb8008

Please sign in to comment.