23d ago

How to use audio with low-level js API?

I have an artboard where audio plays as soon as the screen loads. It works in Rive, but not when I load the artboard with the low-level js api. I'm assuming there's some setup to enable events using the low-level js runtime. Thanks.

2 replies
J
J
23d ago

I haven't tried using this yet but most browsers require a user input to play audio, especially Apple browsers. Are you trying to play it in a browser? Maybe try a quick test to only load the rive file after a button click or bypass the policy in chrome temporarily: https://developer.chrome.com/blog/autoplay/#:%7E:text=chrome.exe%20%2D%2Dautoplay%2Dpolicy%3Dno%2Duser%2Dgesture%2Drequired

23d ago

Yeah, it's definitely that. I can see how they handle it in the high-level api, but there's a lot of code to make it work. I wonder if it'd be easier to use normal events and handle the audio in the code.

Anyone have a more bare bones version that only needs to work after user interaction?