mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-10 22:32:17 +02:00
fix mediasession controls
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { BrowserWindow, globalShortcut, systemPreferences } from 'electron';
|
||||
|
||||
import { isMacOS, isWindows } from '../../../utils';
|
||||
import { isLinux, isMacOS } from '../../../utils';
|
||||
import { store } from '../settings';
|
||||
|
||||
import { PlayerType } from '/@/shared/types/types';
|
||||
@@ -25,10 +25,10 @@ export const enableMediaKeys = (window: BrowserWindow | null) => {
|
||||
}
|
||||
}
|
||||
|
||||
const enableWindowsMediaSession = store.get('mediaSession', false) as boolean;
|
||||
const enableMediaSession = store.get('mediaSession', false) as boolean;
|
||||
const playbackType = store.get('playbackType', PlayerType.WEB) as PlayerType;
|
||||
|
||||
if (!enableWindowsMediaSession || !isWindows() || playbackType !== PlayerType.WEB) {
|
||||
if (!enableMediaSession || isLinux() || playbackType !== PlayerType.WEB) {
|
||||
globalShortcut.register('MediaStop', () => {
|
||||
window?.webContents.send('renderer-player-stop');
|
||||
});
|
||||
|
||||
+7
-2
@@ -477,10 +477,15 @@ async function createWindow(first = true): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
const enableWindowsMediaSession = store.get('mediaSession', false) as boolean;
|
||||
// Only allow hardware media key handling if:
|
||||
// 1. The "Enable Media Session" setting is enabled
|
||||
// 2. The playback type is WEB (mpv not supported)
|
||||
// 3. The platform is not Linux (because we are using mpris instead)
|
||||
const enableMediaSession = store.get('mediaSession', false) as boolean;
|
||||
const playbackType = store.get('playbackType', PlayerType.WEB) as PlayerType;
|
||||
const shouldDisableMediaFeatures =
|
||||
!isWindows() || !enableWindowsMediaSession || playbackType !== PlayerType.WEB;
|
||||
isLinux() || !enableMediaSession || playbackType !== PlayerType.WEB;
|
||||
|
||||
if (shouldDisableMediaFeatures) {
|
||||
app.commandLine.appendSwitch(
|
||||
'disable-features',
|
||||
|
||||
Reference in New Issue
Block a user