Skip to content

Instantly share code, notes, and snippets.

View amol-anand's full-sized avatar

Amol Anand amol-anand

  • Adobe
  • Massachusetts
  • 02:02 (UTC -04:00)
View GitHub Profile
@amol-anand
amol-anand / video-autoplay-snippet.js
Last active February 26, 2024 20:02
Video Autoplay code snippet
const video = document.createElement('video');
video.muted = true; // exactly this way, otherwise it won't play in chrome. Thanks, @msagolj for the tip!
video.toggleAttribute('autoplay', true);
video.toggleAttribute('loop', true);
video.toggleAttribute('playsinline', true);
const source = document.createElement('source');
source.setAttribute('src', entry[2]);
source.setAttribute('type', 'video/mp4');