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",
|
||||
"disableAutomaticUpdates": "disable automatic updates",
|
||||
"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_description": "the application id for {{discord}} rich presence (defaults to {{defaultId}})",
|
||||
"discordIdleStatus": "show rich presence idle status",
|
||||
|
|
|
@ -9,8 +9,6 @@ import { mpvPlayer, mpvPlayerListener } from './preload/mpv-player';
|
|||
import { remote } from './preload/remote';
|
||||
import { utils } from './preload/utils';
|
||||
|
||||
const disableMpv = localSettings.get('disable_mpv');
|
||||
|
||||
contextBridge.exposeInMainWorld('electron', {
|
||||
browser,
|
||||
discordRpc,
|
||||
|
@ -18,8 +16,8 @@ contextBridge.exposeInMainWorld('electron', {
|
|||
localSettings,
|
||||
lyrics,
|
||||
mpris,
|
||||
mpvPlayer: disableMpv ? undefined : mpvPlayer,
|
||||
mpvPlayerListener: disableMpv ? undefined : mpvPlayerListener,
|
||||
mpvPlayer,
|
||||
mpvPlayerListener,
|
||||
remote,
|
||||
utils,
|
||||
});
|
||||
|
|
|
@ -1,44 +1,22 @@
|
|||
import { useMemo } from 'react';
|
||||
import { Center, Group, Stack } from '@mantine/core';
|
||||
import isElectron from 'is-electron';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { RiCheckFill } from 'react-icons/ri';
|
||||
import { Link, Navigate } from 'react-router-dom';
|
||||
import { Button, PageHeader, Text } from '/@/renderer/components';
|
||||
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 { ServerRequired } from '/@/renderer/features/action-required/components/server-required';
|
||||
import { AnimatedPage } from '/@/renderer/features/shared';
|
||||
import { AppRoute } from '/@/renderer/router/routes';
|
||||
import { useCurrentServer } from '/@/renderer/store';
|
||||
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
|
||||
const ActionRequiredRoute = () => {
|
||||
const { t } = useTranslation();
|
||||
const currentServer = useCurrentServer();
|
||||
const isServerRequired = !currentServer;
|
||||
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 = [
|
||||
{
|
||||
component: <MpvRequired />,
|
||||
title: t('error.mpvRequired', { postProcess: 'sentenceCase' }),
|
||||
valid: !isMpvRequired,
|
||||
},
|
||||
{
|
||||
component: <ServerCredentialRequired />,
|
||||
title: t('error.credentialsRequired', { postProcess: 'sentenceCase' }),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
import { SelectItem } from '@mantine/core';
|
||||
import isElectron from 'is-electron';
|
||||
import { Checkbox, Select, Slider, toast } from '/@/renderer/components';
|
||||
import { Select, Slider, toast } from '/@/renderer/components';
|
||||
import {
|
||||
SettingsSection,
|
||||
SettingOption,
|
||||
|
@ -12,15 +12,12 @@ import { PlaybackType, PlayerStatus, PlaybackStyle, CrossfadeStyle } from '/@/re
|
|||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
|
||||
const getAudioDevice = async () => {
|
||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||
return (devices || []).filter((dev: MediaDeviceInfo) => dev.kind === 'audiooutput');
|
||||
};
|
||||
|
||||
const initialDisable = (localSettings?.get('disable_mpv') as boolean | undefined) ?? false;
|
||||
|
||||
export const AudioSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
const settings = usePlaybackSettings();
|
||||
|
@ -28,18 +25,6 @@ export const AudioSettings = () => {
|
|||
const status = useCurrentStatus();
|
||||
|
||||
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(() => {
|
||||
const getAudioDevices = () => {
|
||||
|
@ -60,18 +45,6 @@ export const AudioSettings = () => {
|
|||
}, [settings.type, t]);
|
||||
|
||||
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: (
|
||||
<Select
|
||||
|
@ -98,7 +71,7 @@ export const AudioSettings = () => {
|
|||
context: 'description',
|
||||
postProcess: 'sentenceCase',
|
||||
}),
|
||||
isHidden: !isElectron() || initialDisable || disableMpv,
|
||||
isHidden: !isElectron(),
|
||||
note:
|
||||
status === PlayerStatus.PLAYING
|
||||
? t('common.playerMustBePaused', { postProcess: 'sentenceCase' })
|
||||
|
|
|
@ -5,7 +5,6 @@ import { AppRoute } from '/@/renderer/router/routes';
|
|||
import { useCurrentServer } from '/@/renderer/store';
|
||||
import { toast } from '/@/renderer/components';
|
||||
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
const ipc = isElectron() ? window.electron.ipc : null;
|
||||
const utils = isElectron() ? window.electron.utils : null;
|
||||
|
||||
|
@ -13,20 +12,9 @@ export const AppOutlet = () => {
|
|||
const currentServer = useCurrentServer();
|
||||
|
||||
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 actions = [isServerRequired, isMpvRequired()];
|
||||
const actions = [isServerRequired];
|
||||
const isActionRequired = actions.some((c) => c);
|
||||
|
||||
return isActionRequired;
|
||||
|
|
Reference in a new issue