mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 07:04:31 +00:00
Loader.audiosprite has a new jsonData
parameter. It allows you to pass a pre-existing JSON object (or a string which will be parsed as JSON) to use as the audiosprite data, instead of specifying a URL to a JSON file on the server (thanks @jounii #1447)
Loader.audiosprite has a new `autoDecode` parameter. If `true` the audio file will be decoded immediately upon load.
This commit is contained in:
parent
aa2df803b7
commit
599bcf5f97
3 changed files with 38 additions and 5 deletions
|
@ -126,6 +126,8 @@ Thanks to @pnstickne for vast majority of this update.
|
|||
* ArcadePhysics.distanceToPointer now calculates the distance in world space values.
|
||||
* Sound.fadeIn now supports fading from a marker, as well as the entire audio clip, so now works with audio sprites (thanks @vorrin #1413)
|
||||
* Text font components can now be specified as part of "style". There is a breaking change in that the `fontWeight` now only handles the CSS font-weight component. The `fontStyle` property handles 'italic', 'oblique', values from font-style. This makes the overall consistency cleaner but some code may need to be updated. This does not affect font-weight/font-style as with setStyle({font:..}). Also fixes overwrite font/size/weight oddities - which may result in different behavior for code that was relying on such. All of the text examples appear to work and modification using the new features (while respecting the change in previous behavior) work better (thanks @pnstickne #1375 #1370)
|
||||
* Loader.audiosprite has a new `jsonData` parameter. It allows you to pass a pre-existing JSON object (or a string which will be parsed as JSON) to use as the audiosprite data, instead of specifying a URL to a JSON file on the server (thanks @jounii #1447)
|
||||
* Loader.audiosprite has a new `autoDecode` parameter. If `true` the audio file will be decoded immediately upon load.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -538,7 +538,15 @@ Phaser.Cache.prototype = {
|
|||
decoded = true;
|
||||
}
|
||||
|
||||
this._sounds[key] = { url: url, data: data, isDecoding: false, decoded: decoded, webAudio: webAudio, audioTag: audioTag, locked: this.game.sound.touchLocked };
|
||||
this._sounds[key] = {
|
||||
url: url,
|
||||
data: data,
|
||||
isDecoding: false,
|
||||
decoded: decoded,
|
||||
webAudio: webAudio,
|
||||
audioTag: audioTag,
|
||||
locked: this.game.sound.touchLocked
|
||||
};
|
||||
|
||||
this._resolveURL(url, this._sounds[key]);
|
||||
|
||||
|
|
|
@ -785,14 +785,37 @@ Phaser.Loader.prototype = {
|
|||
* @method Phaser.Loader#audiosprite
|
||||
* @param {string} key - Unique asset key of the audio file.
|
||||
* @param {Array|string} urls - An array containing the URLs of the audio files, i.e.: [ 'audiosprite.mp3', 'audiosprite.ogg', 'audiosprite.m4a' ] or a single string containing just one URL.
|
||||
* @param {string} jsonURL - The URL of the audiosprite configuration json.
|
||||
* @param {string} [jsonURL=null] - The URL of the audiosprite configuration JSON object. If you wish to pass the data directly set this parameter to null.
|
||||
* @param {string|object} [jsonData=null] - A JSON object or string containing the audiosprite configuration data. This is ignored if jsonURL is not null.
|
||||
* @param {boolean} [autoDecode=true] - When using Web Audio the audio files can either be decoded at load time or run-time.
|
||||
* Audio files can't be played until they are decoded and, if specified, this enables immediate decoding. Decoding is a non-blocking async process.
|
||||
* @return {Phaser.Loader} This Loader instance.
|
||||
*/
|
||||
audiosprite: function(key, urls, jsonURL) {
|
||||
audiosprite: function(key, urls, jsonURL, jsonData, autoDecode) {
|
||||
|
||||
this.audio(key, urls);
|
||||
if (typeof jsonURL === 'undefined') { jsonURL = null; }
|
||||
if (typeof jsonData === 'undefined') { jsonData = null; }
|
||||
if (typeof autoDecode === 'undefined') { autoDecode = true; }
|
||||
|
||||
this.json(key + '-audioatlas', jsonURL);
|
||||
this.audio(key, urls, autoDecode);
|
||||
|
||||
if (jsonURL)
|
||||
{
|
||||
this.json(key + '-audioatlas', jsonURL);
|
||||
}
|
||||
else if (jsonData)
|
||||
{
|
||||
if (typeof jsonData === 'string')
|
||||
{
|
||||
jsonData = JSON.parse(jsonData);
|
||||
}
|
||||
|
||||
this.game.cache.addJSON(key + '-audioatlas', '', jsonData);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.warn('Phaser.Loader.audiosprite - You must specify either a jsonURL or provide a jsonData object');
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
|
|
Loading…
Reference in a new issue