I am having trouble getting chrome to autoplay a video. I have set the video to muted and it auto plays in both Safari and Firefox but not chrome.
For those creating elements in JavaScript, here is the JavaScript function I'm using to configure elements to autoplay properly in Chrome:
function configureVideoElementForAutoplay (videoElement) {
videoElement.setAttribute('playsinline', '');
videoElement.setAttribute('muted', '');
videoElement.setAttribute('autoplay', '');
videoElement.muted = true;
}
Example:
let vid = document.createElement('video');
configureVideoElementForAutoplay(vid);
Credit to @Jonny Green for pointing out the necessity of the direct 'muted' property assignment.