2018-05-15 @ 08:29: Autoplay HTML5 videos with sound in Chromium based browsers BrowsersJavaScript

UPDATE: Unfortunately, the following does no longer work with the latest Chromium version. 🙁
 

So, the autoplay policy for HTML5 videos in Chromium based browsers has been changed some time ago to disallow autoplay if the video contains audio. The intent was to not bother the user with sound being played automatically upon visitin a website, and in turn give him an option to selectively choose to have sound turned on/off for HTML5 videos. Well, I’ve found a nifty workaorund which allows you to play videos with sound automatically.

Create a video element as usual:

<video id="myvideo" src="myvideo.mp4" preload="auto" autoplay loop muted></video>

 

As you see the video is muted and will therefore play automatically in Chromium based browsers.

Now add this small JavaScript to unmute the video:

setTimeout(function() {
	var video = document.getElementById("myvideo");
	video.muted = false;
	console.log('Video unmuted.');
}, 1000);

 

This will unmute the video after one second. Bingo! Works like a charm. 🙂

Comments Off on Autoplay HTML5 videos with sound in Chromium based browsers
2017-09-01 @ 14:02: Overkill – A retro space shooter JavaScript

Long time no see. Been busy relocating and doing lots of stuff. One thing I created last week is a retro space shooter in JavaScript based on the WADE game engine using a 2d canvas. It’s quite simple and still work in progress (the graphics need a complete rework), but fully working, yet. Check it out here and get the source code from my GitHub repo.

Comments Off on Overkill – A retro space shooter
2017-03-14 @ 14:28: JQuery dependency removed JavaScript

All JQuery dependencies have been removed from this site, and all functions which used it have been rewritten in plain JavaScript. The advantages are less code, higher speed and no need to take care of external libraries any more.

Comments Off on JQuery dependency removed

  • About

    We never asked for this.