-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Colin Troisemaine
authored and
Colin Troisemaine
committed
Oct 21, 2024
1 parent
9345414
commit f7885d9
Showing
4 changed files
with
76 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> | ||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'"> | ||
<title>Hello World!</title> | ||
<meta http-equiv="Content-Security-Policy" | ||
content="img-src 'self' data: filesystem:; default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; script-src-elem 'self' 'unsafe-eval' https://unpkg.com"> | ||
<title>Live Desktop Translator</title> | ||
</head> | ||
|
||
<body> | ||
<h1>Hello World!</h1> | ||
We are using Node.js <span id="node-version"></span>, | ||
Chromium <span id="chrome-version"></span>, | ||
and Electron <span id="electron-version"></span>. | ||
<div style="text-align: center;"> | ||
<button id="startButton" class="button">Start</button> | ||
<button id="stopButton" class="button">Stop</button> | ||
|
||
<br /> | ||
<br /> | ||
|
||
<video width="800" height="450" autoplay></video> | ||
|
||
<hr /> | ||
|
||
<button id="videoSelectButton" class="button">Choose a Video Source</button> | ||
|
||
<script src="renderer.js"></script> | ||
</div> | ||
</body> | ||
</html> | ||
</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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +0,0 @@ | ||
window.addEventListener('DOMContentLoaded', () => { | ||
const replaceText = (selector, text) => { | ||
const element = document.getElementById(selector) | ||
if (element) element.innerText = text | ||
} | ||
|
||
for (const dependency of ['chrome', 'node', 'electron']) { | ||
replaceText(`${dependency}-version`, process.versions[dependency]) | ||
} | ||
}) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const startButton = document.getElementById('startButton') | ||
const stopButton = document.getElementById('stopButton') | ||
const videoSelectButton = document.getElementById('videoSelectButton') | ||
|
||
const video = document.querySelector('video') | ||
|
||
startButton.addEventListener('click', () => { | ||
console.log("startButton") | ||
navigator.mediaDevices.getDisplayMedia({ | ||
audio: true, | ||
video: { | ||
width: 800, | ||
height: 450, | ||
frameRate: 30 | ||
} | ||
}).then(stream => { | ||
video.srcObject = stream | ||
video.onloadedmetadata = (e) => video.play() | ||
}).catch(e => console.log(e)) | ||
}) | ||
|
||
stopButton.addEventListener('click', () => { | ||
console.log("stopButton") | ||
video.pause() | ||
}) | ||
|
||
// Get the available video sources | ||
const { desktopCapturer } = require('electron') | ||
videoSelectButton.addEventListener('click', () => { | ||
console.log("videoSelectButton") | ||
|
||
const inputSources = desktopCapturer.getSources({ | ||
types: ['window', 'screen'] | ||
}); | ||
|
||
console.log(inputSources) | ||
|
||
}) |