Skip to content

Instantly share code, notes, and snippets.

View nickchauhan's full-sized avatar

Nikhil Chauhan nickchauhan

View GitHub Profile
@nickchauhan
nickchauhan / pause-video-html-video-youtube-vimeo.ts
Created December 1, 2021 11:06
Pause Videos (HTML video / youtube embed/ vimeo embed) programmatically using Javascript / Typescript
// Get all the videos in the slides
const videos: NodeListOf<HTMLVideoElement> = document.querySelectorAll("video");
const iframeVideos: NodeListOf<HTMLIFrameElement> =
document.querySelectorAll("iframe");
// pause all the HTML videos
if (videos.length > 0) {
videos.forEach((videoItem) => {
videoItem.pause();