Blockly. WorkspaceAudio
Class for loading, storing, and playing audio for a workspace.
Constructor
WorkspaceAudio
new WorkspaceAudio(parentWorkspace)
Parameter |
|
---|---|
parentWorkspace |
The parent of the workspace this audio object belongs to, or null. |
Methods
dispose
dispose()
Dispose of this audio manager.
load
load(filenames, name)
Load an audio file. Cache it, ready for instantaneous playing.
Parameter |
|
---|---|
filenames |
Array of string List of file types in decreasing order of preference (i.e. increasing size). E.g. ['media/go.mp3', 'media/go.wav'] Filenames include path from Blockly's root. File extensions matter. Value must not be null. |
name |
string Name of sound. |
play
play(name, opt_volume)
Play a named sound at specified volume. If volume is not specified, use full volume (1).
Parameter |
|
---|---|
name |
string Name of sound. |
opt_volume |
Optional number Volume of sound (0-1). |
preload
preload()
Preload all the audio files so that they play quickly when asked for.