Skip to content

Instantly share code, notes, and snippets.

@Jelmerro
Last active July 12, 2021 13:46
Show Gist options
  • Save Jelmerro/8ffa3b630b3215d4f72a0065fde84908 to your computer and use it in GitHub Desktop.
Save Jelmerro/8ffa3b630b3215d4f72a0065fde84908 to your computer and use it in GitHub Desktop.
Webview autoplay policy
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<div style="display: flex">
<iframe width="300" height="400" src="https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4" title="YouTube video player" frameborder="0" allowfullscreen></iframe>
<webview style="display: flex;height: 400px;width: 300px;" webpreferences="autoplaypolicy=document-user-activation-required" src="https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4"></webview>
</div>
</body>
</html>
const {app, BrowserWindow} = require('electron')
const path = require('path')
app.whenReady().then(() =>{
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
autoplayPolicy: "document-user-activation-required",
webviewTag: true,
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.loadFile('index.html')
})
{
"name": "spiritual-youth-arrive-cvung",
"productName": "spiritual-youth-arrive-cvung",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "jelmerro",
"scripts": {
"start": "electron ."
},
"dependencies": {},
"devDependencies": {
"electron": "13.1.6"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment