Using the isInViewport plugin and jQuery, here’s my code for the task
$('video').each(function(){
if ($(this).is(":in-viewport")) {
$(this)[0].play();
} else {
$(this)[0].pause();
}
})
More Related Contents:
- Retrieving HTML5 video duration separately from the file
- Programmatically play video with sound on Safari and Mobile Chrome
- Detect if HTML5 Video element is playing [duplicate]
- play pause html5 video javascript
- How to change the playing speed of videos in HTML5?
- HTML5 callbacks?
- How can I set preview of video file, selecting from input type=’file’
- Play HTML5 Video when scrolled to
- HTML5 Video: Streaming Video with Blob URLs
- changing source on html5 video tag
- How to handle “Uncaught (in promise) DOMException: play() failed because the user didn’t interact with the document first.” on Desktop with Chrome 66?
- Stop/Close webcam stream which is opened by navigator.mediaDevices.getUserMedia [closed]
- Streaming a video file to an html5 video player with Node.js so that the video controls continue to work?
- HTML 5 video or audio playlist
- Can I use javascript to dynamically change a video’s source?
- JavaScript: Extract video frames reliably
- HTML5 video not streaming and taking 90 seconds to load
- How to mute an html5 video player using jQuery
- Dynamically using the first frame as poster in HTML5 video?
- how to make getUserMedia() work on all browsers
- How to determine the intended frame-rate on an html video element
- canvas.toDataURL() Security Error The operation is insecure
- HTML5 Video – Percentage Loaded?
- How to detect supported video formats for the HTML5 video tag?
- HTML5 Video buffered attribute features
- How often does the timeupdate event fire for an html5 video
- Create thumbnail from video file via file input
- Checking if a html5 video is ready
- Media Source Api not working for a custom webm file (Chrome Version 23.0.1271.97 m)
- Redirect html5 video after play