w3pmjg
Last Updated: November 20, 2017
·
9
· tomas2387
40276387b66caf2bbf4e1b764da1b807

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';
Say Thanks
Respond