视频自动播放autoplay无法播放需要静音,setTimeout0.1后执行点击一次,隐藏掉播放按钮
<body>
<button onclick="playPause()" id="buttonid" style="display: none;">播放/暂停</button>
<video src="QQ视频20210827100340.mp4" controls="controls" id="video1">
your browser does not support the video tag
</video>
</body>
<script type="text/javascript">
var myVideo=document.getElementById("video1");
function playPause()
{
if (myVideo.paused)
myVideo.play();
else
myVideo.pause();
}
function makeBig()
{
myVideo.width=560;
}
function makeSmall()
{
myVideo.width=320;
}
function makeNormal()
{
myVideo.width=420;
}
setTimeout(function(){
document.getElementById("buttonid").click();
}, 0.1);
</script>