mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 02:13:33 +00:00
Prevent Media Session Handling on MPV (#1212)
* Remove MediaSession Handling on MPV * Add playbackType to config.json for Main Thread Access * Disabling settings without Hiding
This commit is contained in:
parent
0ca9eb0fcd
commit
829c27a5e9
5 changed files with 24 additions and 7 deletions
|
|
@ -7,6 +7,7 @@ import {
|
|||
} from '/@/renderer/features/settings/components/settings-section';
|
||||
import { useHotkeySettings, usePlaybackSettings, useSettingsStoreActions } from '/@/renderer/store';
|
||||
import { Switch } from '/@/shared/components/switch/switch';
|
||||
import { PlaybackType } from '/@/shared/types/types';
|
||||
|
||||
const localSettings = isElectron() ? window.api.localSettings : null;
|
||||
const isWindows = isElectron() ? window.api.utils.isWindows() : false;
|
||||
|
|
@ -15,14 +16,19 @@ export const WindowHotkeySettings = () => {
|
|||
const { t } = useTranslation();
|
||||
const settings = useHotkeySettings();
|
||||
const { setSettings } = useSettingsStoreActions();
|
||||
const { mediaSession: enableWindowsMediaSession } = usePlaybackSettings();
|
||||
const { mediaSession: enableWindowsMediaSession, type: playbackType } = usePlaybackSettings();
|
||||
|
||||
const options: SettingOption[] = [
|
||||
{
|
||||
control: (
|
||||
<Switch
|
||||
defaultChecked={settings.globalMediaHotkeys}
|
||||
disabled={!isElectron() || (enableWindowsMediaSession && isWindows)}
|
||||
disabled={
|
||||
!isElectron() ||
|
||||
(enableWindowsMediaSession &&
|
||||
isWindows &&
|
||||
playbackType === PlaybackType.WEB)
|
||||
}
|
||||
onChange={(e) => {
|
||||
setSettings({
|
||||
hotkeys: {
|
||||
|
|
@ -44,7 +50,7 @@ export const WindowHotkeySettings = () => {
|
|||
context: 'description',
|
||||
postProcess: 'sentenceCase',
|
||||
}),
|
||||
isHidden: !isElectron() || (enableWindowsMediaSession && isWindows),
|
||||
isHidden: !isElectron(),
|
||||
title: t('setting.globalMediaHotkeys', { postProcess: 'sentenceCase' }),
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ import { Switch } from '/@/shared/components/switch/switch';
|
|||
import { toast } from '/@/shared/components/toast/toast';
|
||||
import { CrossfadeStyle, PlaybackStyle, PlaybackType, PlayerStatus } from '/@/shared/types/types';
|
||||
|
||||
const ipc = isElectron() ? window.api.ipc : null;
|
||||
|
||||
const getAudioDevice = async () => {
|
||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||
return (devices || []).filter((dev: MediaDeviceInfo) => dev.kind === 'audiooutput');
|
||||
|
|
@ -62,6 +64,7 @@ export const AudioSettings = ({ hasFancyAudio }: { hasFancyAudio: boolean }) =>
|
|||
disabled={status === PlayerStatus.PLAYING}
|
||||
onChange={(e) => {
|
||||
setSettings({ playback: { ...settings, type: e as PlaybackType } });
|
||||
ipc?.send('settings-set', { property: 'playbackType', value: e });
|
||||
if (isElectron() && e === PlaybackType.LOCAL) {
|
||||
const queueData = usePlayerStore.getState().actions.getPlayerData();
|
||||
setQueue(queueData);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import {
|
|||
} from '/@/renderer/features/settings/components/settings-section';
|
||||
import { usePlaybackSettings, useSettingsStoreActions } from '/@/renderer/store/settings.store';
|
||||
import { Switch } from '/@/shared/components/switch/switch';
|
||||
import { PlaybackType } from '/@/shared/types/types';
|
||||
|
||||
const isWindows = isElectron() ? window.api.utils.isWindows() : null;
|
||||
const isDesktop = isElectron();
|
||||
|
|
@ -14,7 +15,7 @@ const ipc = isElectron() ? window.api.ipc : null;
|
|||
|
||||
export const MediaSessionSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
const { mediaSession } = usePlaybackSettings();
|
||||
const { mediaSession, type: playbackType } = usePlaybackSettings();
|
||||
const { toggleMediaSession } = useSettingsStoreActions();
|
||||
|
||||
function handleMediaSessionChange() {
|
||||
|
|
@ -29,6 +30,7 @@ export const MediaSessionSettings = () => {
|
|||
<Switch
|
||||
aria-label="Toggle media Session"
|
||||
defaultChecked={mediaSession}
|
||||
disabled={!isWindows || !isDesktop || playbackType !== PlaybackType.WEB}
|
||||
onChange={handleMediaSessionChange}
|
||||
/>
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue