Muting an embedded Youtube video

I’m trying to mute an embed video from youtube in a rectangle’s inner html

<iframe id="ytplayer" width="1080" height="920" src="https://www.youtube.com/embed/uMJpLCmRweA?&amp;html5-1&amp;enablejsapi=1&amp;autoplay=1" frameborder="0" allowfullscreen=""></iframe>

and then running the following function on Scene Load:

    var tag = document.createElement('script');

    tag.src = "https://www.youtube.com/iframe_api";
    var firstScriptTag = document.getElementsByTagName('script')[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

    var player;

    function onYouTubeIframeAPIReady() {
        player = new YT.Player('ytplayer', {
            events: {
                'onReady': onPlayerReady
            }
        });
    }

    function onPlayerReady() {
        player.playVideo();
        // Mute!
        player.mute();
    }

It works fine normal HTML files which means the code is OK, but it’s not working in hype 3 pro.
Can someone help me ?

tks

Can you share your document?

Here it is @Daniel
thanks

VideoBG Overlay with Button.hype.zip (12.9 KB)

Hey @gcapedro did you get this figured out? I’m having the same issue.

Editing my previous post: I found that simply embedding the script inside the HTML widget, rather than to call it on scene load, solved the problem.

Here is our guide for Youtube embedding & stopping audio when switching scenes: Custom Video Embedding: Youtube, Vimeo, or hosted video files | Stopping Audio when exiting the scene