Skip to content

Instantly share code, notes, and snippets.

@JustinDFuller
Last active January 6, 2017 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JustinDFuller/ca8d3fe08f2d00ec7b04f1cd4853f79a to your computer and use it in GitHub Desktop.
Save JustinDFuller/ca8d3fe08f2d00ec7b04f1cd4853f79a to your computer and use it in GitHub Desktop.
Autoplay Video
const videoContainer = document.getElementById('myVideoID');
const suppressAutoplayForUser = /* Use an external service like a database to fill this in */
const video = document.createElement('video');
video.autoplay = suppressAutoplayForUser ? false : true;
video.src = 'myAwesomeVideo.mp4';
video.textContent = 'Your browser does not support this media type, or the Video tag.';
videoContainer.appendChild(video);
/* Creates:
<div id='myVideoID'>
<video src='myAwesomeVideo.mp4' autoplay>
Your browser does not support this media type, or the Video tag.
</video>
</div>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment