audio(key, urls, autoDecode) → {Phaser.Loader}
Adds an audio file to the current load queue.
The file is not loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.
The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.
Retrieve the file via Cache.getSound(key)
.
The URL can be relative or absolute. If the URL is relative the Loader.baseURL
and Loader.path
values will be prepended to it.
Mobile warning: There are some mobile devices (certain iPad 2 and iPad Mini revisions) that cannot play 48000 Hz audio.
When they try to play the audio becomes extremely distorted and buzzes, eventually crashing the sound system.
The solution is to use a lower encoding rate such as 44100 Hz.
Parameters
Name | Type | Argument | Default | Description |
---|---|---|---|---|
key | string | Unique asset key of the audio file. | ||
urls | string | Array.<string> | Array.<object> | Either a single string or an array of URIs or pairs of | ||
autoDecode | boolean | <optional> | true | When using Web Audio the audio files can either be decoded at load time or run-time. |
Returns
This Loader instance.
- Source code: loader/Loader.js (Line 991)
Please login to continue.