HTML5 Video muted but still playing

后端 未结 9 1469
闹比i
闹比i 2021-02-05 02:38

Title pretty much says it all. I have a video which automatically starts playing when arriving on the page.

In the HTML code I have put muted=\"muted\". And here comes

9条回答
  •  离开以前
    2021-02-05 03:05

    I'm not entirely sure as to why the muted attribute is malfunctioning when defined within the video tag. However, this is what you can do :

    Firstly, remove the muted="muted" attribute from the video tag. Keep it simply as :

    
    

    Now, define a function that on loading of the page, mutes the video.

    window.onload = function () {
        var element = document.getElementById('video');
        element.muted = "muted";
    }
    

    I have verified this, and it works.

提交回复
热议问题