Skip to content

Commit c1010bd

Browse files
Added support for passing in json object instead of url to json file directly to audioSprite loader method
1 parent 6145ff5 commit c1010bd

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

v3/src/scene/plugins/Loader.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var BaseLoader = require('../../loader/BaseLoader');
22
var Class = require('../../utils/Class');
33
var NumberArray = require('../../utils/array/NumberArray');
4+
var CONST = require('../../loader/const');
45

56
var AnimationJSONFile = require('../../loader/filetypes/AnimationJSONFile');
67
var AtlasJSONFile = require('../../loader/filetypes/AtlasJSONFile');
@@ -124,7 +125,23 @@ var Loader = new Class({
124125

125126
if(audioFile)
126127
{
127-
var jsonFile = new JSONFile(key, json, this.path, jsonXhrSettings);
128+
var jsonFile;
129+
130+
if (typeof json === 'string')
131+
{
132+
jsonFile = new JSONFile(key, json, this.path, jsonXhrSettings);
133+
134+
this.addFile(jsonFile);
135+
}
136+
else
137+
{
138+
jsonFile = {
139+
type: 'json',
140+
key: key,
141+
data: json,
142+
state: CONST.FILE_WAITING_LINKFILE
143+
};
144+
}
128145

129146
// Link them together
130147
audioFile.linkFile = jsonFile;
@@ -135,7 +152,6 @@ var Loader = new Class({
135152
jsonFile.linkType = 'audioSprite';
136153

137154
this.addFile(audioFile);
138-
this.addFile(jsonFile);
139155
}
140156

141157
return this;

0 commit comments

Comments
 (0)