<audio>

Imports an audio file.

Warning: This tag is obsolete. Its functionality has been replaced by the <resource> tag.

The <resource> tag defines another way to import a sound into an application. The <resource> tag can also be used to import images and movies.

The <audio> tag imports an audio file. The file is included in the application when the application is compiled. The tag has a required src attribute. The value of this attribute is a filename, that is resolved relative to the source file that contains the <audio> tag. The file should contain an mp3 file.

The LzAudio service can be used from JavaScript to play the clip. The string that is passed to the LzAudio.playSound method should match the value of the name attribute of an audio tag.

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

Also see the audio example.

The audio clip must be an MP3 file at one of the following sample rates: 11.025 khz, 22.5 khz, and 44.1 khz, and encoded at no more than 160kbps.

Attributes
Name Usage Type (Tag) Type (JS) Default Category
id Tag only ID   final
 

A unique identifier for this element. Can be used as a global variable name in JavaScript code.


name Tag only token   final
 

The name of a variable that will be set to this object when the application is started. If this element is directly within a <canvas> or <library> element, the global variable and the canvas property with this name will be set to this object. If this element is within another object, that object's property with this name will be set to this object.


src Tag only URL   final
 

The path of a file that contains the source for this object.