HTML:
<video width="100%" height="300" id="video" style="object-fit:fill;"> <source src="https://video.mp4" type="video/mp4"> </video>
<img src="../images/video.png" id="video2">
JS:
<script type="text/javascript">
var video2=document.getElementById("video2"); var myVideo=document.getElementById("video"); video2.onclick = function(){ video2.style.display = "none"; var vList = ['https://video.mp4']; var vLen = vList.length; var curr = 0; myVideo.addEventListener('ended', function () { //监听视频是否已经结束事件 playVid(); }); function playVid() { myVideo.src = vList[curr]; myVideo.load(); myVideo.play(); curr++; if (curr >= vLen) { curr = 0; //重新循环播放 } } $(function () { playVid(); }) }
</script>