Class: WorkspaceAudio
Defined in: packages/blockly/core/workspace_audio.ts:29
Class for loading, storing, and playing audio for a workspace.
Methods index
| Method | Description |
|---|---|
| load | Load an audio file. Cache it, ready for instantaneous playing. |
| play | Play a named sound at specified volume. If volume is not specified, use full volume (1). |
| beep | Plays a beep at the given frequency. |
| playErrorBeep | Plays a standard error beep. |
| setMuted | - |
| getMuted | Returns whether the audio is currently muted or not. |
Constructors
Constructor
new WorkspaceAudio(parentWorkspace): WorkspaceAudio;
Defined in: packages/blockly/core/workspace_audio.ts:46
Parameters
| Parameter | Type | Description |
|---|---|---|
parentWorkspace | WorkspaceSvg | The parent of the workspace this audio object belongs to if it has one, or the workspace that owns this instance. |
Returns
WorkspaceAudio
Methods
load()
load(filenames, name): Promise<void>;
Defined in: packages/blockly/core/workspace_audio.ts:69
Load an audio file. Cache it, ready for instantaneous playing.
Parameters
| Parameter | Type | Description |
|---|---|---|
filenames | string[] | Single-item array containing the URL for the sound file. Any items after the first item are ignored. |
name | string | Name of sound. |
Returns
Promise<void>
play()
play(name, opt_volume?): Promise<void>;
Defined in: packages/blockly/core/workspace_audio.ts:88
Play a named sound at specified volume. If volume is not specified, use full volume (1).
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Name of sound. |
opt_volume? | number | Volume of sound (0-1). |
Returns
Promise<void>
beep()
beep(tone, duration?): Promise<void>;
Defined in: packages/blockly/core/workspace_audio.ts:123
Plays a beep at the given frequency.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
tone | number | undefined | The frequency of the beep to play, in hertz. |
duration | number | 0.2 | The duration of the beep, in seconds. Defaults to 0.2. |
Returns
Promise<void>
playErrorBeep()
playErrorBeep(): Promise<void>;
Defined in: packages/blockly/core/workspace_audio.ts:152
Plays a standard error beep.
Returns
Promise<void>
setMuted()
setMuted(muted): void;
Defined in: packages/blockly/core/workspace_audio.ts:225
Parameters
| Parameter | Type | Description |
|---|---|---|
muted | boolean | If true, mute sounds. Otherwise, play them. |
Returns
void
getMuted()
getMuted(): boolean;
Defined in: packages/blockly/core/workspace_audio.ts:232
Returns
boolean
Whether the audio is currently muted or not.