Class AudioJS
Defined in: arcade.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
AudioJS(opts)
Sound support based on <audio> element.
|
| Field Attributes | Field Name and Description |
|---|---|
| <static> |
AudioJS.audioObjSupport
true, if browser supports the Audio class.
|
| <static> |
AudioJS.basicAudioSupport
true, if browser supports Audio.play().
|
| <static> |
AudioJS.loopSupport
true if browser supports looping (repeating)
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
AudioJS.load(url)
Load and cache audio element for this URL.
|
|
play(loop)
Play this sound.
|
|
|
toString()
Return string representation.
|
Class Detail
AudioJS(opts)
Sound support based on <audio> element.
var clickSound = new AudioJS('click.wav')
var sound2 = new AudioJS(['click.ogg', 'click.mp3'])
var sound3 = new AudioJS({src: ['click.ogg', 'click.mp3'], loop: true)
[...]
clickSound.play();
- Parameters:
- {string|string[]|object} opts
- Audio URL, list of URLs or option dictionary.
- {string|string[]} opts.src
- Audio URL or list of URLs.
- {boolean} opts.loop Optional, Default: false
- {float} opts.volume Optional, Default: 1
Field Detail
<static>
AudioJS.audioObjSupport
true, if browser supports the Audio class.
<static>
AudioJS.basicAudioSupport
true, if browser supports Audio.play().
<static>
AudioJS.loopSupport
true if browser supports looping (repeating)
Method Detail
<static>
AudioJS.load(url)
Load and cache audio element for this URL.
This internal function is called by the constructor.
- Parameters:
- {string} url
play(loop)
Play this sound.
- Parameters:
- {boolean} loop
- Optional, default: false
{string}
toString()
Return string representation.
- Returns:
- {string}