Last active
July 12, 2021 13:46
-
-
Save Jelmerro/8ffa3b630b3215d4f72a0065fde84908 to your computer and use it in GitHub Desktop.
Webview autoplay policy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Empty */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment