The Coders Blog
The Coders Blog Author of The Coders Blog. Also a professional fullstack javascript developer working with various tech company and client around world.

Auto play video in electron app with sound using HTML 5 video element

Feb 11, 2019 · 1 min
Auto play video in electron app with sound using HTML 5 video element

Chrome restrict webpage to auto play video with sound. As electron app use chrome behind the scene this restriction does apply to electron app. But electron app is used to build desktop app and you might need to override this behaviors.

With electron you can override such setting by command line api which is under app. Video from local source or url can be played with audio by pasting following command inside create window function.

app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required")

Turning off web security in electron

Similarly electron app / chrome has there own security measure to secure user from venerable website.You might want some access to user machine for desktop app but default security might stop you. In that case you can turn off the default web security using following flag while creating window.

  
    mainWindow = new BrowserWindow({
    kiosk: true,
    webSecurity: false
    });