Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/blocks/scratch3_sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ class Scratch3SoundBlocks {
sound_set_stop_fadeout_to: this.setStopFadeout,
sound_play_at_seconds: this.playAtSeconds,
sound_play_at_seconds_until_done: this.playAtSecondsAndWait,
sound_getSoundVolume: this.currentSoundVolume
sound_getSoundVolume: this.currentSoundVolume,
sound_currentlyPlayingSounds: this.playingSounds,
};
}

Expand All @@ -174,19 +175,23 @@ class Scratch3SoundBlocks {
isSpriteSpecific: true,
getId: (targetId, fields) => getMonitorIdForBlockWithArgs(`${targetId}_soundgetEffectValue`, fields)
},
sound_currentlyPlayingSounds: {
isSpriteSpecific: true,
getId: targetId => `${targetId}_currentlyPlayingSounds`
}
};
}

currentSoundVolume (args, util) {

}

playAtSeconds (args, util) {
const seconds = Cast.toNumber(args.VALUE);
if (seconds < 0) {
return;
}

this._playSoundAtTimePosition({
sound: Cast.toString(args.SOUND_MENU),
seconds: seconds
Expand Down Expand Up @@ -306,7 +311,7 @@ class Scratch3SoundBlocks {
const target = util.target;
const sprite = target.sprite;
if (!sprite) return;

const { soundId } = sprite.sounds[index];

const soundBank = sprite.soundBank
Expand Down Expand Up @@ -532,6 +537,21 @@ class Scratch3SoundBlocks {
effectsMenu (args) {
return args.EFFECT;
}

playingSounds(args, util) {
const sprite = util.target.sprite;
return JSON.stringify(
Object.entries(sprite.soundBank.soundPlayers)
.filter(
([_, player]) =>
player.isPlaying
)
.map(
([key, _]) =>
sprite.sounds.find(({soundId}) => soundId === key).name
)
);
}
}

module.exports = Scratch3SoundBlocks;
3 changes: 2 additions & 1 deletion src/compiler/compat-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ const outputBlocks = [
'operator_xnor',
'looks_getinputofcostume',
'sound_getTimePosition',
'sound_getSoundVolume'
'sound_getSoundVolume',
'sound_currentlyPlayingSounds',
];

module.exports = {
Expand Down