Skip to content

Commit 1d83317

Browse files
Merge pull request #747 from processing/worklets-instance-mode
patch audioWorklet.addModule instance mode
2 parents d795d3b + d72d035 commit 1d83317

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/audioWorklet/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ let initializedAudioWorklets = false;
99

1010
function loadAudioWorkletModules() {
1111
return Promise.all(
12-
moduleSources.map(function (moduleSrc) {
12+
moduleSources.map(function(moduleSrc) {
1313
const blob = new Blob([moduleSrc], { type: 'application/javascript' });
1414
const objectURL = URL.createObjectURL(blob);
15-
return ac.audioWorklet.addModule(objectURL);
16-
})
17-
);
15+
return ac.audioWorklet
16+
.addModule(objectURL)
17+
// in "p5 instance mode," the module may already be registered
18+
.catch(() => Promise.resolve());
19+
}));
1820
}
1921

2022
p5.prototype.registerMethod('init', function () {

0 commit comments

Comments
 (0)