Double click required at first load

Hello everyone
I made a custom button to mute audio on an embedded vimeo video in webflow, all through a embed code component.

the embedded code is this


<div style="padding:56.25% 0 0 0;position:relative;">
    <iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" id="embeddedVideo" src="https://player.vimeo.com/video/874737818?h=cff6a1077a&background=1&autoplay=1&loop=1&title=0&byline=0&portrait=0" frameborder="0" allowfullscreen allow="autoplay; encrypted-media"></iframe>

<button id="mute" class="mute-on" onclick="myScript()"></button>

</div>
<script src="https://player.vimeo.com/api/player.js"></script>

<script>
document.addEventListener('DOMContentLoaded', function () {
    var iframe = document.getElementById('embeddedVideo');
    var player = new Vimeo.Player(iframe);
    var mute = document.getElementById('mute');

    // Wait for the player to be ready before setting up the click handler
    player.ready().then(function() {
        mute.addEventListener('click', function() {
            player.getVolume().then(function(volume) {
                if (volume === 0) {
                    player.setVolume(1); // Unmute
                    mute.classList.remove("mute-on");
                    mute.classList.add("mute-off");
                } else {
                    player.setVolume(0); // Mute
                    mute.classList.remove("mute-off");
                    mute.classList.add("mute-on");
                }
            }).catch(function(error) {
                console.error("Error:", error);
            });
        });
    });
});
</script>

All is working fine except at the first load of the page, to interact with the button I have to click twice! anyone knows how to handle that issue?

Here is the link to the website: limiteazero.webflow.io
Here is the read only link: https://preview.webflow.com/preview/limiteazero?utm_medium=preview_link&utm_source=designer&utm_content=limiteazero&preview=a2a0a207b4ee9d1e216b130041700366&workflow=preview

Thanks in advance
Jacopo