我使用一个按钮来调用函数“play()”,使视频全屏播放
<div style="text-align:center">
<form>
<input type="button" name="something" value="start_experiment" onclick="play(this,vid)">
</form>
</div>
<video id="vid" width="320" height="240" class="rounded-circle" >
<source src="assets/vid/video.mp4" type="video/mp4" >
</video>
<script>
function play(button,vidid) {
button.style.visibility = "hidden";
var myVideo = vidid;
if (myVideo.requestFullscreen) {
myVideo.requestFullscreen();
}
else if (myVideo.msRequestFullscreen) {
myVideo.msRequestFullscreen();
}
else if (myVideo.mozRequestFullScreen) {
myVideo.mozRequestFullScreen();
}
else if (myVideo.webkitRequestFullScreen) {
myVideo.webkitRequestFullScreen();
}
myVideo.play();
}
</script>
如何让视频在停止播放时自动最小化?
最佳答案
.onished()
该函数在结束视频中使用。
结束事件发生在音频/视频结束时。
此事件对于“感谢收听”、“感谢观看”等消息很有用。
示例:-
var vid = document.getElementById("vid");
vid.onended = function() {
alert("The video has ended");
this.exitFullscreen();
/*any this you add this function*/
};
关于javascript - 如何让视频结束时自动最小化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64635914/