Hi,
Long story short: This stems from trying to get an audio toggle on a video strip (as it’s the only way to get full width video). The code I have written works in preview, but then it’s another matter on the test site. On the initial page load, I get varied results across different desktops, most of the time no sound at all.
What I noticed is that on all computers, when you navigate to the about page, and then back to the home page, then everything runs like clockwork and the audio works just fine. What I want to work out is why that works, but the initial page load doesn’t.
Does anyone know what I can do to replicate that experience, but on the initial page load?
I have a lot of code running on this site for various functions, but can show all if anyone needs it.
Test site in question: https://breakscape.wixsite.com/website-3
(Video strip may take some time to expand)
If you need to see the code behind that section:
Video strip with audio code (just a hidden audio player for the sound):
$w.onReady(function () {
$w('#audioPlayer1').volume = 30;
setTimeout(function () {
$w('#audioPlayer1').play()
$w('#columnStrip2').expand()
}, 200);
})
Volume is at 30 so I can hear when the player loads. The switch is just an onChange event linked to the .volume options on the audio player.
Just wanted you to know that I’m looking at this, but haven’t figured it out yet.
A couple of points:
Is the audio supposed to start when the site loads? If so, you should set the toggle switch to “on”:

Also, you have a couple “warnings” (==) in your code that you should “fix” (===):

I don’t believe the above issues would make a difference, but they’re worth taking care of in any case.
Instead of toggling by setting the volume (0 or 100), you probably should use mute() and unmute() . After all, that’s what there for. Not to mention that the developers spent time developing these functions just for you! How do you think they feel about you ignoring their work?
Hi Yisrael,
Thanks for taking the time to look at my site.
In reply to your points:
-
With the toggle, I left if off as while I want the audio to play when the site loads, I want it to be muted. With the toggle linked to the volume (off = 0, on = 100), leaving it on would result in audio you can hear when the site loads. I’m leaving it up to the user to decide if they would like to have the audio, otherwise the default is muted.
-
With the warnings, I had originally had them set at ===, but this resulted in a total loss of audio on load for some reason. I couldn’t work it out, but just as a test I switched it to == and it provided a more consistent result. Defies logic but that seems to be the case with this whole issue! I’ll try some more variables with === though and see if I can get results.
-
With the .mute() / .unmute() I had tried those too, but it actually makes no difference to the issue. I switched to the .volume as then I could set it to a low level when testing, this way I can here when the audio track loads and starts playing (but secretly I just like upsetting developers)!
Any ideas on why the initial page load may produce a different result to loading the home page after visiting another page on the site?
Does the site code load one single time, or is it run again each time a user changes the page?
Just if you’re interested, here’s a different version of the site that uses a slightly different method to load the audio & video strip, but has the same unfortunate result: https://www.archerygames.ca/
Thanks again, I really appreciate you taking the time to help!