-1
I’m trying to force an autoplay on videos with javascript, but with videos not mute, with mute video is very simple, but with it with volume works 50%, for example, if I access the video page by clicking another page the autoplay runs, because there was user interference, but in case you are already on the video page and give a F5 the browser reads as something programmed, without user interference and error.
I know this is possible because on Youtube even you giving F5 the video with audio is played automatically, probably there is some event that is allowed this, what I am currently using is briefly the following:
document.addEventListener('DOMContentLoaded',function(e){
setTimeout(function(){
document.querySelector('video').play();
},1000);
});
And the mistake that comes when trying to give the autoplay with video with audio by F5 is the promise:
Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.
has already tried using Event Document.ready?
– Vitor Ceolin
Initially it used jQuery, but then I passed all the scope of video script to pure JS, but with jQuery it was the same result as Domcontentloaded.
– Henri Azevedo
Well, I don’t know how to help then, but is it really a good idea to start the page with sound? Because if such video is not the main purpose of the page it is usually unpleasant to open a page and start leaving audio without you waiting, especially if you are in a public or work environment (Zap moan that says)
– Vitor Ceolin
The application I’m doing is from a specific audience, there will be no random videos like Youtube, it was just the same example, but actually already works autoplay but only with clicks and Mousemove, I wanted to see if updating the page or in some other way also give.. like letting the autoplay go round
– Henri Azevedo
Some browsers block and only allow if the user even click.
– user178974