I have a video that was uploaded to my html page and with the help of javascript I can put the video in full screen by clicking on a button. When that happens I can detect it without problem.
The following code allows me to put the video in full screen when I click on a button:
// Here the video in html
<video controls id="myvideo">
<source src="/videoPlays.mp4" type="video/mp4"></source>
</video>
// here javascript/jquery code to active fullscreen mode and play video
$("#BtnPlayVideo").click(VideoPlay);
function VideoPlay() {
var elem = document.getElementById("myvideo");
if (elem.requestFullscreen) {
elem.requestFullscreen();
$('#myvideo')[0].play();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
$('#myvideo')[0].play();
} else if (elem.webkitRequestFullscreen) {
elem.webkitRequestFullscreen();
$('#myvideo')[0].play();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
$('#myvideo')[0].play();
}
}
What I want to do is to detect when the user presses the button to leave the full screen mode and stop the video at that moment. Any ideas or help that you can give me to achieve this?