<!DOCTYPE html>

<html>


<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>JS 自动播放视频</title>

</head>


<body>

    <video width="640" height="360">

        <source src="your-video-url.mp4" type="video/mp4">

        你的浏览器不支持视频播放。

    </video>

    <video width="640" height="360">

        <source src="another-video-url.mp4" type="video/mp4">

        你的浏览器不支持视频播放。

    </video>

    <script>

        document.addEventListener('DOMContentLoaded', function () {

            const videos = document.querySelectorAll('video');

            videos.forEach(function (video) {

                video.muted = true;

                video.play().catch(error => {

                    console.error('视频自动播放失败:', error);

                });

            });

        });

    </script>

</body>


</html>