Last active
February 26, 2024 20:02
-
-
Save amol-anand/f797e6ab9513898e132987dabcaca262 to your computer and use it in GitHub Desktop.
Video Autoplay code snippet
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
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'); | |
video.append(source); | |
slide.append(video); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment