I use a button that calls the function “play()” that make the video play on fullscreen
JavaScript
x
33
33
1
<div style="text-align:center">
2
<form>
3
<input type="button" name="something" value="start_experiment" onclick="play(this,vid)">
4
</form>
5
</div>
6
7
<video id="vid" width="320" height="240" class="rounded-circle" >
8
<source src="assets/vid/video.mp4" type="video/mp4" >
9
</video>
10
11
<script>
12
13
function play(button,vidid) {
14
button.style.visibility = "hidden";
15
var myVideo = vidid;
16
17
if (myVideo.requestFullscreen) {
18
myVideo.requestFullscreen();
19
}
20
else if (myVideo.msRequestFullscreen) {
21
myVideo.msRequestFullscreen();
22
}
23
else if (myVideo.mozRequestFullScreen) {
24
myVideo.mozRequestFullScreen();
25
}
26
else if (myVideo.webkitRequestFullScreen) {
27
myVideo.webkitRequestFullScreen();
28
}
29
30
myVideo.play();
31
}
32
</script>
33
How could I make the video auto-minimized when it stops playing?
Advertisement
Answer
.onended()
this function use in end video.
The ended event occurs when the audio/video has reached the end.
This event is useful for messages like “thanks for listening”, “thanks for watching”, etc.
example:-
JavaScript
1
7
1
var vid = document.getElementById("vid");
2
vid.onended = function() {
3
alert("The video has ended");
4
this.exitFullscreen();
5
/*any this you add this function*/
6
};
7