Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
body, html {
padding: 0;
margin: 0;
width: 100%;
height: 100vh;
}
#vid {
width: 100%;
height: 100vh;
object-fit: cover;
}
</style>
</head>
<body>
<video id="vid" autoplay loop />
</body>
<script>
const vid = document.getElementById('vid');
vid.src = `http://localhost:${window.location.search.substr(1)}/video.mp4`;
vid.play();
</script>
</html>
import fs from 'fs';
import { app, BrowserWindow, screen } from 'electron';
import express from 'express';
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
app.quit();
}
const windows = [];
const PORT = process.env.PORT || 4231;
const DEFAULT_WINDOW_OPTS = {
type: 'desktop',
frame: false,
};
function createWindow(display) {
const { bounds } = display;
const { x, y, width, height } = bounds;
const win = new BrowserWindow({
...DEFAULT_WINDOW_OPTS,
x,
y,
width,
height,
});
win.loadURL(`file://${__dirname}/index.html?${PORT}`);
windows.push(win);
}
function initElectron() {
const screens = screen.getAllDisplays();
screens.forEach(createWindow);
}
function createServer() {
const srv = express();
srv.get('/:video', (req, res) => {
const { video } = req.params;
fs.createReadStream(`${__dirname}/${video}`).pipe(res);
});
srv.listen(PORT, () => {
initElectron();
});
}
app.on('ready', createServer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.