Trigger action if Autoplay doesn't work

Hello everyone,

new to Wix and Velo. I took a few courses of coding in JS ages ago, but have forgotten most things and have relied on the internet to get me through so far.

I’m having trouble with my website on certain browsers. I have a few videoplayers that should autoplay, which works fine on most computers. For some though, either their device or browser is blocking autoplay.
This most likely has something to do with privacy and safety settings, which I obviously don’t want to mess with.

My hot-fix is to check if the first video on the page is playing. If not, I want a button to appear and alert the user that they could change their browser settings to allow autoplay. Here is the code I’ve been trying to use:

export function videoBox1_play_1 ( event ) {

   $w ( "#section9" ). collapse (); 

}

The way I was hoping it would work is that once Video Box 1 is detected to play (meaning autoplay works) Section 9 (which is the section telling the user to switch browser settings) Will collapse. I’m testing this out and it doesnt seem to be working. The Section either is hidden all the time, or is shown all the time. It doen’t seem to be reacting to if auoplay is enabled or not.

Can anyone tell me what I’m doing wrong? Is there a smarter solution to checking is a user has enabled autoplay on Wix?

Many thanks!