Source
static Future<SoundSprite> load(
String url, [SoundLoadOptions soundLoadOptions]) async {
SoundSprite soundSprite = new SoundSprite();
var soundSpriteJson = await HttpRequest.getString(url);
var data = JSON.decode(soundSpriteJson);
var urls = data['urls'] as List;
var segments = data["sprite"];
var soundUrls = new List<String>();
if (segments is Map) {
for (String segment in segments.keys) {
var segmentList = segments[segment] as List;
var startTime = ensureNum(segmentList[0]);
var duration = ensureNum(segmentList[1]);
var loop = ensureBool(segmentList.length > 2 && segmentList[2]);
var sss = new SoundSpriteSegment(soundSprite, segment, startTime, duration, loop);
soundSprite._segments.add(sss);
}
}
soundUrls.addAll(urls.map((String u) => replaceFilename(url, u)));
soundLoadOptions = (soundLoadOptions ?? Sound.defaultLoadOptions).clone();
soundLoadOptions.alternativeUrls = soundUrls.skip(1).toList();
soundSprite._sound = await Sound.load(soundUrls[0], soundLoadOptions);
return soundSprite;
}