[canvaskit] perform audio asset lookup by layer id

Change-Id: Iac56d11a76be8d90df1159631a02f1713ece1bd8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368938
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Jorge Betancourt <jmbetancourt@google.com>
This commit is contained in:
Jorge Betancourt 2021-02-10 15:49:48 -05:00 committed by Skia Commit-Bot
parent 80aa5b1365
commit 1352d0e47d
3 changed files with 6 additions and 4 deletions

View File

@ -8,6 +8,8 @@
// prop_filter_prefix is an optional string acting as a name filter for selecting
// "interesting" Lottie properties (surfaced in the embedded player controls)
// soundMap is an optional object that maps string names to AudioPlayers
// AudioPlayers manage a single audio layer with a seek function
CanvasKit.MakeManagedAnimation = function(json, assets, prop_filter_prefix, soundMap) {
if (!CanvasKit._MakeManagedAnimation) {
throw 'Not compiled with MakeManagedAnimation';

View File

@ -70,9 +70,9 @@ public:
}
sk_sp<skresources::ExternalTrackAsset> loadAudioAsset(const char[] /* path */,
const char name[],
const char[] /*id*/) override {
emscripten::val player = this->findSoundAsset(name);
const char[] /* name */,
const char id[]) override {
emscripten::val player = this->findSoundAsset(id);
if (player.as<bool>()) {
return sk_make_sp<WebTrack>(std::move(player));
}

View File

@ -97,7 +97,7 @@ describe('Skottie behavior', () => {
}
}
for (let i = 0; i < 20; i++) {
var name = 'aud_' + i + '.mp3';
var name = 'audio_' + i;
mockSoundMap.setPlayer(name, new mockPlayer(name));
}
fetch('/assets/audio_external.json')