Skip to content

Instantly share code, notes, and snippets.

@BinaryMuse
Created October 3, 2017 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BinaryMuse/ea10d5d7044c119a8fd493c1466b2d9d to your computer and use it in GitHub Desktop.
Save BinaryMuse/ea10d5d7044c119a8fd493c1466b2d9d to your computer and use it in GitHub Desktop.
<!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