Created
April 4, 2024 11:28
-
-
Save hassanuos/7c971da2cba4a65635a85784f8d5a6c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<script> | |
function handleVisibilityChange() { | |
let videoSelector = document.querySelector('video'); | |
if(document.hidden) { | |
videoSelector.pause(); | |
console.log('Video Paused!!!!'); | |
} else { | |
videoSelector.play(); | |
console.log('Video Played!!!!'); | |
} | |
} | |
document.addEventListener("visibilitychange", handleVisibilityChange, false); | |
</script> | |
<body> | |
<h1>The video element</h1> | |
<video width="320" height="240" controls> | |
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4"> | |
</video> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment