@grame/faust-web-component 0.2.10 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/faust-web-component.js +41 -41
- package/package.json +1 -1
- package/src/faust-editor.ts +5 -1
- package/src/faust-widget.ts +5 -1
package/package.json
CHANGED
package/src/faust-editor.ts
CHANGED
@@ -449,8 +449,12 @@ export default class FaustEditor extends HTMLElement {
|
|
449
449
|
if (node && node.numberOfInputs > 0) {
|
450
450
|
if (deviceId == "Audio File") {
|
451
451
|
try {
|
452
|
+
// Extract the base URL (excluding the script filename)
|
453
|
+
const scriptTag = document.querySelector('script[src$="faust-web-component.js"]');
|
454
|
+
const scriptSrc = scriptTag.src;
|
455
|
+
const baseUrl = scriptSrc.substring(0, scriptSrc.lastIndexOf('/') + 1);
|
452
456
|
// Load the file
|
453
|
-
let file = await fetch('02-XYLO1.mp3');
|
457
|
+
let file = await fetch(baseUrl + '02-XYLO1.mp3');
|
454
458
|
const arrayBuffer = await file.arrayBuffer();
|
455
459
|
let audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
|
456
460
|
// Create a source node from the buffer
|
package/src/faust-widget.ts
CHANGED
@@ -218,8 +218,12 @@ export default class FaustWidget extends HTMLElement {
|
|
218
218
|
if (node && node.numberOfInputs > 0) {
|
219
219
|
if (deviceId == "Audio File") {
|
220
220
|
try {
|
221
|
+
// Extract the base URL (excluding the script filename)
|
222
|
+
const scriptTag = document.querySelector('script[src$="faust-web-component.js"]');
|
223
|
+
const scriptSrc = scriptTag.src;
|
224
|
+
const baseUrl = scriptSrc.substring(0, scriptSrc.lastIndexOf('/') + 1);
|
221
225
|
// Load the file
|
222
|
-
let file = await fetch('02-XYLO1.mp3');
|
226
|
+
let file = await fetch(baseUrl + '02-XYLO1.mp3');
|
223
227
|
const arrayBuffer = await file.arrayBuffer();
|
224
228
|
let audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
|
225
229
|
// Create a source node from the buffer
|