So I have a site where users would want to demo audio output produced by a server side script. They select some options and hit a create button. I then AJAX in a HTML5 audio ele
Help for future answer seekers, an ideal way to check if auto-play supported or not by the browsers/devices:
var promise = document.getElementById('video').play();
if( typeof promise !== 'undefined' ) {
promise.then(function() {
// auto-play started!
}).catch(function(error) {
// auto-play failed
});
}
Please note, media play promise is not supported by all browsers yet. In case if browser doesn't support it, it will return undefined
.