Remove "disable mpv" setting and desktop requirement
This commit is contained in:
parent
eb4d099804
commit
ff4ce89bc9
5 changed files with 5 additions and 70 deletions
|
@ -428,8 +428,6 @@
|
||||||
"customFontPath_description": "sets the path to the custom font to use for the application",
|
"customFontPath_description": "sets the path to the custom font to use for the application",
|
||||||
"disableAutomaticUpdates": "disable automatic updates",
|
"disableAutomaticUpdates": "disable automatic updates",
|
||||||
"disableLibraryUpdateOnStartup": "disable checking for new versions on startup",
|
"disableLibraryUpdateOnStartup": "disable checking for new versions on startup",
|
||||||
"disableMpv": "Disable MPV",
|
|
||||||
"disableMpv_description": "If checked, prevent MPV from starting and bypass MPV requirement.",
|
|
||||||
"discordApplicationId": "{{discord}} application id",
|
"discordApplicationId": "{{discord}} application id",
|
||||||
"discordApplicationId_description": "the application id for {{discord}} rich presence (defaults to {{defaultId}})",
|
"discordApplicationId_description": "the application id for {{discord}} rich presence (defaults to {{defaultId}})",
|
||||||
"discordIdleStatus": "show rich presence idle status",
|
"discordIdleStatus": "show rich presence idle status",
|
||||||
|
|
|
@ -9,8 +9,6 @@ import { mpvPlayer, mpvPlayerListener } from './preload/mpv-player';
|
||||||
import { remote } from './preload/remote';
|
import { remote } from './preload/remote';
|
||||||
import { utils } from './preload/utils';
|
import { utils } from './preload/utils';
|
||||||
|
|
||||||
const disableMpv = localSettings.get('disable_mpv');
|
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('electron', {
|
contextBridge.exposeInMainWorld('electron', {
|
||||||
browser,
|
browser,
|
||||||
discordRpc,
|
discordRpc,
|
||||||
|
@ -18,8 +16,8 @@ contextBridge.exposeInMainWorld('electron', {
|
||||||
localSettings,
|
localSettings,
|
||||||
lyrics,
|
lyrics,
|
||||||
mpris,
|
mpris,
|
||||||
mpvPlayer: disableMpv ? undefined : mpvPlayer,
|
mpvPlayer,
|
||||||
mpvPlayerListener: disableMpv ? undefined : mpvPlayerListener,
|
mpvPlayerListener,
|
||||||
remote,
|
remote,
|
||||||
utils,
|
utils,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,44 +1,22 @@
|
||||||
import { useMemo } from 'react';
|
|
||||||
import { Center, Group, Stack } from '@mantine/core';
|
import { Center, Group, Stack } from '@mantine/core';
|
||||||
import isElectron from 'is-electron';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { RiCheckFill } from 'react-icons/ri';
|
import { RiCheckFill } from 'react-icons/ri';
|
||||||
import { Link, Navigate } from 'react-router-dom';
|
import { Link, Navigate } from 'react-router-dom';
|
||||||
import { Button, PageHeader, Text } from '/@/renderer/components';
|
import { Button, PageHeader, Text } from '/@/renderer/components';
|
||||||
import { ActionRequiredContainer } from '/@/renderer/features/action-required/components/action-required-container';
|
import { ActionRequiredContainer } from '/@/renderer/features/action-required/components/action-required-container';
|
||||||
import { MpvRequired } from '/@/renderer/features/action-required/components/mpv-required';
|
|
||||||
import { ServerCredentialRequired } from '/@/renderer/features/action-required/components/server-credential-required';
|
import { ServerCredentialRequired } from '/@/renderer/features/action-required/components/server-credential-required';
|
||||||
import { ServerRequired } from '/@/renderer/features/action-required/components/server-required';
|
import { ServerRequired } from '/@/renderer/features/action-required/components/server-required';
|
||||||
import { AnimatedPage } from '/@/renderer/features/shared';
|
import { AnimatedPage } from '/@/renderer/features/shared';
|
||||||
import { AppRoute } from '/@/renderer/router/routes';
|
import { AppRoute } from '/@/renderer/router/routes';
|
||||||
import { useCurrentServer } from '/@/renderer/store';
|
import { useCurrentServer } from '/@/renderer/store';
|
||||||
|
|
||||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
|
||||||
|
|
||||||
const ActionRequiredRoute = () => {
|
const ActionRequiredRoute = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const currentServer = useCurrentServer();
|
const currentServer = useCurrentServer();
|
||||||
const isServerRequired = !currentServer;
|
const isServerRequired = !currentServer;
|
||||||
const isCredentialRequired = false;
|
const isCredentialRequired = false;
|
||||||
|
|
||||||
const isMpvRequired = useMemo(() => {
|
|
||||||
if (!localSettings) return false;
|
|
||||||
|
|
||||||
const mpvPath = localSettings.get('mpv_path');
|
|
||||||
if (mpvPath) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const mpvDisabled = localSettings.get('disable_mpv');
|
|
||||||
return !mpvDisabled;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const checks = [
|
const checks = [
|
||||||
{
|
|
||||||
component: <MpvRequired />,
|
|
||||||
title: t('error.mpvRequired', { postProcess: 'sentenceCase' }),
|
|
||||||
valid: !isMpvRequired,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
component: <ServerCredentialRequired />,
|
component: <ServerCredentialRequired />,
|
||||||
title: t('error.credentialsRequired', { postProcess: 'sentenceCase' }),
|
title: t('error.credentialsRequired', { postProcess: 'sentenceCase' }),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { SelectItem } from '@mantine/core';
|
import { SelectItem } from '@mantine/core';
|
||||||
import isElectron from 'is-electron';
|
import isElectron from 'is-electron';
|
||||||
import { Checkbox, Select, Slider, toast } from '/@/renderer/components';
|
import { Select, Slider, toast } from '/@/renderer/components';
|
||||||
import {
|
import {
|
||||||
SettingsSection,
|
SettingsSection,
|
||||||
SettingOption,
|
SettingOption,
|
||||||
|
@ -12,15 +12,12 @@ import { PlaybackType, PlayerStatus, PlaybackStyle, CrossfadeStyle } from '/@/re
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
||||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
|
||||||
|
|
||||||
const getAudioDevice = async () => {
|
const getAudioDevice = async () => {
|
||||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||||
return (devices || []).filter((dev: MediaDeviceInfo) => dev.kind === 'audiooutput');
|
return (devices || []).filter((dev: MediaDeviceInfo) => dev.kind === 'audiooutput');
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialDisable = (localSettings?.get('disable_mpv') as boolean | undefined) ?? false;
|
|
||||||
|
|
||||||
export const AudioSettings = () => {
|
export const AudioSettings = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const settings = usePlaybackSettings();
|
const settings = usePlaybackSettings();
|
||||||
|
@ -28,18 +25,6 @@ export const AudioSettings = () => {
|
||||||
const status = useCurrentStatus();
|
const status = useCurrentStatus();
|
||||||
|
|
||||||
const [audioDevices, setAudioDevices] = useState<SelectItem[]>([]);
|
const [audioDevices, setAudioDevices] = useState<SelectItem[]>([]);
|
||||||
const [disableMpv, setDisableMpv] = useState(initialDisable);
|
|
||||||
|
|
||||||
const handleSetDisableMpv = (disabled: boolean) => {
|
|
||||||
setDisableMpv(disabled);
|
|
||||||
localSettings?.set('disable_mpv', disabled);
|
|
||||||
|
|
||||||
if (disabled) {
|
|
||||||
setSettings({
|
|
||||||
playback: { ...settings, type: disabled ? PlaybackType.WEB : PlaybackType.LOCAL },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getAudioDevices = () => {
|
const getAudioDevices = () => {
|
||||||
|
@ -60,18 +45,6 @@ export const AudioSettings = () => {
|
||||||
}, [settings.type, t]);
|
}, [settings.type, t]);
|
||||||
|
|
||||||
const audioOptions: SettingOption[] = [
|
const audioOptions: SettingOption[] = [
|
||||||
{
|
|
||||||
control: (
|
|
||||||
<Checkbox
|
|
||||||
defaultChecked={disableMpv}
|
|
||||||
onChange={(e) => handleSetDisableMpv(e.currentTarget.checked)}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
description: t('setting.disableMpv', { context: 'description' }),
|
|
||||||
isHidden: !isElectron(),
|
|
||||||
note: t('common.restartRequired', { postProcess: 'sentenceCase' }),
|
|
||||||
title: t('setting.disableMpv'),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
control: (
|
control: (
|
||||||
<Select
|
<Select
|
||||||
|
@ -98,7 +71,7 @@ export const AudioSettings = () => {
|
||||||
context: 'description',
|
context: 'description',
|
||||||
postProcess: 'sentenceCase',
|
postProcess: 'sentenceCase',
|
||||||
}),
|
}),
|
||||||
isHidden: !isElectron() || initialDisable || disableMpv,
|
isHidden: !isElectron(),
|
||||||
note:
|
note:
|
||||||
status === PlayerStatus.PLAYING
|
status === PlayerStatus.PLAYING
|
||||||
? t('common.playerMustBePaused', { postProcess: 'sentenceCase' })
|
? t('common.playerMustBePaused', { postProcess: 'sentenceCase' })
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { AppRoute } from '/@/renderer/router/routes';
|
||||||
import { useCurrentServer } from '/@/renderer/store';
|
import { useCurrentServer } from '/@/renderer/store';
|
||||||
import { toast } from '/@/renderer/components';
|
import { toast } from '/@/renderer/components';
|
||||||
|
|
||||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
|
||||||
const ipc = isElectron() ? window.electron.ipc : null;
|
const ipc = isElectron() ? window.electron.ipc : null;
|
||||||
const utils = isElectron() ? window.electron.utils : null;
|
const utils = isElectron() ? window.electron.utils : null;
|
||||||
|
|
||||||
|
@ -13,20 +12,9 @@ export const AppOutlet = () => {
|
||||||
const currentServer = useCurrentServer();
|
const currentServer = useCurrentServer();
|
||||||
|
|
||||||
const isActionsRequired = useMemo(() => {
|
const isActionsRequired = useMemo(() => {
|
||||||
const isMpvRequired = () => {
|
|
||||||
if (!localSettings) return false;
|
|
||||||
const mpvPath = localSettings.get('mpv_path');
|
|
||||||
if (mpvPath) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const mpvDisabled = localSettings.get('disable_mpv');
|
|
||||||
return !mpvDisabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
const isServerRequired = !currentServer;
|
const isServerRequired = !currentServer;
|
||||||
|
|
||||||
const actions = [isServerRequired, isMpvRequired()];
|
const actions = [isServerRequired];
|
||||||
const isActionRequired = actions.some((c) => c);
|
const isActionRequired = actions.some((c) => c);
|
||||||
|
|
||||||
return isActionRequired;
|
return isActionRequired;
|
||||||
|
|
Reference in a new issue