mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-06-24 21:25:23 +00:00
Electron: Added support for changing main window background
This commit is contained in:
parent
e7168b0a74
commit
62e430c080
5 changed files with 69 additions and 2 deletions
|
@ -1,19 +1,21 @@
|
|||
import { BrowserWindow, ipcMain, IpcMainEvent, nativeImage, Tray, Menu, dialog, shell } from 'electron';
|
||||
import { ToastIcon } from 'common/components/Toast';
|
||||
import { Opcode, PlaybackErrorMessage, PlaybackUpdateMessage, VolumeUpdateMessage, PlayMessage, PlayUpdateMessage, EventMessage, EventType, ContentObject, ContentType, PlaylistContent, SeekMessage, SetVolumeMessage, SetSpeedMessage, SetPlaylistItemMessage } from 'common/Packets';
|
||||
import { Opcode, PlaybackErrorMessage, PlaybackUpdateMessage, VolumeUpdateMessage, PlayMessage, PlayUpdateMessage, EventMessage, EventType, PlaylistContent, SeekMessage, SetVolumeMessage, SetSpeedMessage, SetPlaylistItemMessage } from 'common/Packets';
|
||||
import { DiscoveryService } from 'common/DiscoveryService';
|
||||
import { TcpListenerService } from 'common/TcpListenerService';
|
||||
import { WebSocketListenerService } from 'common/WebSocketListenerService';
|
||||
import { ConnectionMonitor } from 'common/ConnectionMonitor';
|
||||
import { Logger, LoggerType } from 'common/Logger';
|
||||
import { MediaCache } from 'common/MediaCache';
|
||||
import { supportedImageExtensions, supportedVideoExtensions } from 'common/MimeTypes';
|
||||
import { Settings } from 'common/Settings';
|
||||
import { preparePlayMessage } from 'common/UtilityBackend';
|
||||
import { Updater } from './Updater';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import { preparePlayMessage } from 'common/UtilityBackend';
|
||||
const cp = require('child_process');
|
||||
let logger = null;
|
||||
|
||||
|
@ -426,6 +428,25 @@ export class Main {
|
|||
|
||||
networkWorker.loadFile(path.join(__dirname, 'main/worker.html'));
|
||||
});
|
||||
|
||||
Main.mainWindow.webContents.once('dom-ready', () => {
|
||||
if (Settings.json.ui.mainWindowBackground !== '') {
|
||||
if (fs.existsSync(Settings.json.ui.mainWindowBackground)) {
|
||||
if (supportedVideoExtensions.find(ext => ext === path.extname(Settings.json.ui.mainWindowBackground).toLocaleLowerCase())) {
|
||||
Main.mainWindow?.webContents?.send("update-background", Settings.json.ui.mainWindowBackground, true);
|
||||
}
|
||||
else if (supportedImageExtensions.find(ext => ext === path.extname(Settings.json.ui.mainWindowBackground).toLocaleLowerCase())) {
|
||||
Main.mainWindow?.webContents?.send("update-background", Settings.json.ui.mainWindowBackground, false);
|
||||
}
|
||||
else {
|
||||
logger.warn(`Custom background at ${Settings.json.ui.mainWindowBackground} is not of a supported file format. Ignoring...`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger.warn(`Custom background at ${Settings.json.ui.mainWindowBackground} does not exist. Ignoring...`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static async main(app: Electron.App) {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="main-container">
|
||||
<img id="image-background"/>
|
||||
<video id="video-player" class="video" autoplay loop>
|
||||
<source src="../assets/video/background.mp4" type="video/mp4">
|
||||
</video>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue