简体   繁体   中英

Why won't the video element auto-play?

I made this html code to simulate a Windows 95 Startup sequence. Here it is:

<!DOCTYPE html>
<html style="background-color: #000000">
<head>
    <title>Windows 95 Startup</title>
</head>
<body>
    <script src="https://code.jquery.com/jquery-2.1.0.js"></script>
    <script>
        var startup = function () {
            $("body").append('<center><img src="https://springsadvertiser.co.za/wp-content/uploads/sites/28/2016/01/win95-hero.jpg"></center><video controls autoplay><source src="https://www.winhistory.de/more/winstart/down/o95.wav" type="audio/wav"></video>');
        };
        setTimeout(startup, 10000);
    </script>
</body>
</html>

Why won't the video element auto-play, and how do I fix it to auto-play without being muted?

Unfortunately for you, a video on autoplay has to be muted. You can mute the audio using the muted keyword as <video controls muted autoplay><source src="https://www.winhistory.de/more/winstart/down/o95.wav" type="audio/wav"></video> . But, I doubt this is what you want to do.
Edit: This is due to Autoplay Policy Changes .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM