lz.AudioService
This service manages audio resource playback. Check canvas.capabilities.audio to ensure your runtime supports audio.

JavaScript: lz.AudioService

lz.Audio is the single instance of the class lz.AudioService.

<canvas height="150">
  <audio src="resources/poof.mp3" name="poof"/>
  <button text="Poof" onclick="lz.Audio.playSound('poof');"/>
</canvas>

Class Attributes

Name (CSS property) Type (tag) Type (js) Default Category
LzAudio   lz.AudioService   readonly
  The audio service. Also available as the global lz.Audio.

Methods

getPan()
lz.AudioService.getPan();
Get the global pan.
Returns Type Description
  Number linear pan from -100 to +100 (left to right)

getVolume()
lz.AudioService.getVolume();
Get the global volume
Returns Type Description
  Number volume from 0 to 100 (0 is silent).

playSound()
lz.AudioService.playSound(snd : String);
Sets the current sound resource and starts playing it.
Parameter Name Type Description
snd String Name of a sound resource to play

setPan()
lz.AudioService.setPan(p : Number);
Set the global pan.
Parameter Name Type Description
p Number linear pan from -100 to +100 (left to right)

setVolume()
lz.AudioService.setVolume(v : Number);
Set the global volume.
Parameter Name Type Description
v Number linear volume from 0 to 100 (0 is silent).

startSound()
lz.AudioService.startSound();
Start playing the current sound

stopSound()
lz.AudioService.stopSound();
Stop playing the current sound