Created
July 30, 2018 17:05
-
-
Save zehfernandes/8ba4d8159fcf303d4ac0754f6dbde390 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
videos = document.querySelectorAll('video') | |
videos.forEach(function(element) { | |
var promise = element.play(); | |
if (promise !== undefined) { | |
promise.then(_ => { | |
// Autoplay started! | |
}).catch(error => { | |
element.setAttribute("controls","controls") | |
}); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment