• I’ve been trying to create a button that enables/disables video audio.

    I’m using a background video, and I’ve been trying to add JS to disable or enable the video audio

    Since window.YT is already loaded, I’m ignoring it.

    I’ve added some JS to my hello-elementor theme. The function loadPlayer() is being loaded after verifying that the element widget2 exists. widget2 is the iframe where the youtube video is.

    var player;
    function loadPlayer() {
        player = new YT.Player('widget2');
    }
    
    function toggleSound() {
        if (player.isMuted()) {
            player.unMute();
        } else {
            player.mute();
        }
    }

    For some reason this is not working. player is always undefined.

    My question is if there’s any way to access through elementor Frontend functions the video that’s currently playing, instead of needing to create a new Player object

  • The topic ‘Background video with enable/disable audio’ is closed to new replies.