Referenced Assets Issue

I’ve having some issues with loading referenced assets on our platform using the Web (JS) framework.

 

We have created a small RIVE file that when a button is pressed, triggers an mp3 file to play.

What we are trying to do is to localize that file for the language that the user in our platform has chosen and loading the correct mp3 file

 

I’ve added this code to the Initialization of the Rive object and I’m trying to set the asset bytes array like this: asset.bytes = new Uint8Array(buffer);

 

assetLoader: async (asset, bytes) => {

    // Check if this is our referenced audio asset.

    if (asset.isAudio && asset.name === "PowerOfRive") {

        // If no bytes are embedded (i.e. it's a referenced asset)

        if (bytes.length === 0) {

            // Use currentLanguage to pick the correct audio file.

            const url = audioSourcesPowerOfRive[currentLanguage] || audioSourcesPowerOfRive["en"];

            try {

                const response = await fetch(url);

                if (!response.ok) {

                    throw new Error(`HTTP error! Status: ${response.status}`);

                }

                const buffer = await response.arrayBuffer();

                asset.bytes = new Uint8Array(buffer);

                console.log("AssetLoader: Loaded audio asset for", currentLanguage);

                return true; // Indicate that we handled this asset.

            } catch (err) {

                console.error("AssetLoader error for audio asset:", err);

                return false;

            }

        }

    } else {

        // Log other assets to verify they are not being intercepted.

        if (asset.isFont) {

            console.log("AssetLoader: encountered font asset:", asset.name);

            randomFontAsset(asset);

            return true;

        }

    }

    return false;

},

 

But when I press the button the mp3 file won’t play.

 

I’ve done a similar thing with the fonts and that works fine, as you can see above and it does change the fonts accordingly.