AutoPlay HLS videos
Due to recent autoplay policies, hls autoplaying is now pretty easy to do.
https://webkit.org/blog/7734/auto-play-policy-changes-for-macos/
//We listen when we can play our video hls
video.addEventListener('canplaythrough', function () {
var promise = video.play();
if (promise !== undefined) {
promise.catch(function(error) {
console.error('Auto-play was prevented');
console.error('We Show a UI element to let the user manually start playback');
buttonPlay.style.display = 'block';
}).then(function() {
console.info('Auto-play started');
buttonPlay.style.display = 'none';
});
}
}); // Fires when the browser can play through the audio/video without stopping for buffering
video.muted = 'muted';
video.autoplay = 'autoplay';
video.playsinline = 'true';
Written by Tomás
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Hls
Authors
Tomás Prado
9.001K
knoopx
1.64K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#