Skip to content

Instantly share code, notes, and snippets.

@jmercouris
Created March 8, 2024 03:06
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 jmercouris/fca7cba9d8e6b30a2f861268a3180cff to your computer and use it in GitHub Desktop.
Save jmercouris/fca7cba9d8e6b30a2f861268a3180cff to your computer and use it in GitHub Desktop.
browser window
const { app, net, protocol, BrowserWindow } = require('electron')
const path = require('path')
const { pathToFileURL } = require('url')
protocol.registerSchemesAsPrivileged([
{
scheme: 'a',
privileges: {
standard: true,
stream: true,
}
}
]);
protocol.registerSchemesAsPrivileged([
{
scheme: 'b',
privileges: {
standard: false,
stream: false,
}
}
]);
app.whenReady().then(() => {
protocol.handle('a', (req) => {
const { host, pathname } = new URL(req.url);
return new Response('<audio controls src="https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3"></audio>', {
headers: { 'content-type': 'text/html' }
})
})
});
app.whenReady().then(() => {
protocol.handle('b', (req) => {
const { host, pathname } = new URL(req.url);
return new Response('<audio controls src="https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3"></audio>', {
headers: { 'content-type': 'text/html' }
})
})
});
function createWindow() {
const aWindow = new BrowserWindow()
aWindow.loadURL('a:')
const bWindow = new BrowserWindow()
bWindow.loadURL('b:')
}
app.whenReady().then(() => {
createWindow()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment