Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable9.0] cherry pick blockly sound fix #9753

Merged
merged 1 commit into from
Oct 26, 2023
Merged
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
1 change: 1 addition & 0 deletions localtypings/pxtarget.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ declare namespace pxt {
matchWebUSBDeviceInSim?: boolean; // if set, pass current device id as theme to sim when available.
condenseProfile?: boolean; // if set, will make the profile dialog smaller
cloudProfileIcon?: string; // the file path for added imagery on smaller profile dialogs
blocklySoundVolume?: number; // A number between 0 and 1 that sets the volume for blockly sounds (e.g. connect, disconnect, click)
}

interface DownloadDialogTheme {
Expand Down
14 changes: 13 additions & 1 deletion webapp/src/blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,19 @@ export class Editor extends toolboxeditor.ToolboxEditor {

const oldAudioPlay = (Blockly as any).WorkspaceAudio.prototype.play;
(Blockly as any).WorkspaceAudio.prototype.play = function (name: string, opt_volume?: number) {
if (editor && editor.parent.state.mute) opt_volume = 0;
const themeVolume = pxt.appTarget?.appTheme?.blocklySoundVolume;

if (editor?.parent.state.mute === pxt.editor.MuteState.Muted) {
opt_volume = 0;
}
else if (themeVolume != undefined) {
if (opt_volume != undefined) {
opt_volume *= themeVolume;
}
else {
opt_volume = themeVolume;
}
}
oldAudioPlay.call(this, name, opt_volume);
};
}
Expand Down
Loading