Disable chromium autoplay policies in electron

Since Electron updated its Chromium version, it has adopted by default the policy of disabling auto-play from Chrome 66.

This includes having the user interact with the page before auto-play occurs. This isn’t ideal behaviour for say digital signage where no one interacts with it, or if you have an intro screen video for a kiosk.

To get around this, the following code works like a charm:

const app = electron.app
app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');

Published by Matt van der Haas

Matthew van der Haas is a lively, motivated, professional yet sarcastic web developer who loves nothing better than exploring new technology. Having not being used to writing in the third person, Matthew tells a story of how he's had over 10 years of professional web experience, and experience in front of a computer since he opened his eyes. At a small age Matthew was described as knee-cam, due to being interested in taking video when he was as tall as the height of peoples knees. Matthew also enjoys the hardware side of things, enjoys good old fashioned tidy soldering and wiring job, as well as playing with GPIOs on the Raspberry PI

Leave a comment

Your email address will not be published. Required fields are marked *