1
0
Fork 0
mirror of https://gitlab.com/futo-org/fcast.git synced 2025-06-24 21:25:23 +00:00

Electron: Reload viewer window when viewing supported content type

This commit is contained in:
Michael Hollister 2025-05-13 00:22:24 -05:00
parent b08b233f02
commit 269006ffb1

View file

@ -28,6 +28,7 @@ export class Main {
static tray: Tray;
private static cachedInterfaces = null;
private static playerWindowContentViewer = null;
private static toggleMainWindow() {
if (Main.mainWindow) {
@ -156,7 +157,9 @@ export class Main {
const listeners = [Main.tcpListenerService, Main.webSocketListenerService];
listeners.forEach(l => {
l.emitter.on("play", async (message) => {
if (Main.playerWindow == null) {
const contentViewer = supportedPlayerTypes.find(v => v === message.container.toLocaleLowerCase()) ? 'player' : 'viewer';
if (!Main.playerWindow) {
Main.playerWindow = new BrowserWindow({
fullscreen: true,
autoHideMenuBar: true,
@ -169,17 +172,25 @@ export class Main {
Main.playerWindow.setAlwaysOnTop(false, 'pop-up-menu');
Main.playerWindow.show();
const rendererPath = supportedPlayerTypes.find(v => v === message.container.toLocaleLowerCase()) ? 'player' : 'viewer';
Main.playerWindow.loadFile(path.join(__dirname, `${rendererPath}/index.html`));
Main.playerWindow.loadFile(path.join(__dirname, `${contentViewer}/index.html`));
Main.playerWindow.on('ready-to-show', async () => {
Main.playerWindow?.webContents?.send("play", await NetworkService.proxyPlayIfRequired(message));
});
Main.playerWindow.on('closed', () => {
Main.playerWindow = null;
Main.playerWindowContentViewer = null;
});
}
else if (Main.playerWindow && contentViewer !== Main.playerWindowContentViewer) {
Main.playerWindow.loadFile(path.join(__dirname, `${contentViewer}/index.html`));
Main.playerWindow.on('ready-to-show', async () => {
Main.playerWindow?.webContents?.send("play", await NetworkService.proxyPlayIfRequired(message));
});
} else {
Main.playerWindow?.webContents?.send("play", await NetworkService.proxyPlayIfRequired(message));
}
Main.playerWindowContentViewer = contentViewer;
});
l.emitter.on("pause", () => Main.playerWindow?.webContents?.send("pause"));
@ -188,6 +199,7 @@ export class Main {
l.emitter.on("stop", () => {
Main.playerWindow?.close();
Main.playerWindow = null;
Main.playerWindowContentViewer = null;
});
l.emitter.on("seek", (message) => Main.playerWindow?.webContents?.send("seek", message));