mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
Add mpv path option
This commit is contained in:
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
|
|||||||
import { Divider, Group, SelectItem, Stack } from '@mantine/core';
|
import { Divider, Group, SelectItem, Stack } from '@mantine/core';
|
||||||
import isElectron from 'is-electron';
|
import isElectron from 'is-electron';
|
||||||
import {
|
import {
|
||||||
|
FileInput,
|
||||||
NumberInput,
|
NumberInput,
|
||||||
SegmentedControl,
|
SegmentedControl,
|
||||||
Select,
|
Select,
|
||||||
@@ -12,6 +13,10 @@ import {
|
|||||||
} from '@/renderer/components';
|
} from '@/renderer/components';
|
||||||
import { mpvPlayer } from '@/renderer/features/player/utils/mpv-player';
|
import { mpvPlayer } from '@/renderer/features/player/utils/mpv-player';
|
||||||
import { SettingsOptions } from '@/renderer/features/settings/components/settings-option';
|
import { SettingsOptions } from '@/renderer/features/settings/components/settings-option';
|
||||||
|
import {
|
||||||
|
getLocalSetting,
|
||||||
|
setLocalSetting,
|
||||||
|
} from '@/renderer/features/settings/utils/local-settings';
|
||||||
import { usePlayerStore } from '@/renderer/store';
|
import { usePlayerStore } from '@/renderer/store';
|
||||||
import { useSettingsStore } from '@/renderer/store/settings.store';
|
import { useSettingsStore } from '@/renderer/store/settings.store';
|
||||||
import {
|
import {
|
||||||
@@ -40,6 +45,21 @@ export const PlaybackTab = () => {
|
|||||||
const update = useSettingsStore((state) => state.setSettings);
|
const update = useSettingsStore((state) => state.setSettings);
|
||||||
const status = usePlayerStore((state) => state.current.status);
|
const status = usePlayerStore((state) => state.current.status);
|
||||||
const [audioDevices, setAudioDevices] = useState<SelectItem[]>([]);
|
const [audioDevices, setAudioDevices] = useState<SelectItem[]>([]);
|
||||||
|
const [mpvPath, setMpvPath] = useState('');
|
||||||
|
|
||||||
|
const handleSetMpvPath = (e: File) => {
|
||||||
|
setLocalSetting('mpv_path', e.path);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const getMpvPath = async () => {
|
||||||
|
if (!isElectron()) return setMpvPath('');
|
||||||
|
const mpvPath = await getLocalSetting('mpv_path');
|
||||||
|
return setMpvPath(mpvPath);
|
||||||
|
};
|
||||||
|
|
||||||
|
getMpvPath();
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getAudioDevices = () => {
|
const getAudioDevices = () => {
|
||||||
@@ -84,6 +104,19 @@ export const PlaybackTab = () => {
|
|||||||
status === PlayerStatus.PLAYING ? 'Player must be paused' : undefined,
|
status === PlayerStatus.PLAYING ? 'Player must be paused' : undefined,
|
||||||
title: 'Audio player',
|
title: 'Audio player',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
control: (
|
||||||
|
<FileInput
|
||||||
|
placeholder={mpvPath}
|
||||||
|
width={225}
|
||||||
|
onChange={handleSetMpvPath}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
description: 'The location of your MPV executable',
|
||||||
|
isHidden: settings.type !== PlaybackType.LOCAL,
|
||||||
|
note: 'Restart required',
|
||||||
|
title: 'MPV executable path',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
control: (
|
control: (
|
||||||
<Select
|
<Select
|
||||||
@@ -97,7 +130,7 @@ export const PlaybackTab = () => {
|
|||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
description: 'The audio device to use for playback (web player only)',
|
description: 'The audio device to use for playback (web player only)',
|
||||||
isHidden: !isElectron(),
|
isHidden: !isElectron() || settings.type !== PlaybackType.WEB,
|
||||||
title: 'Audio device',
|
title: 'Audio device',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -118,7 +151,7 @@ export const PlaybackTab = () => {
|
|||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
description: 'Adjust the playback style (web player only)',
|
description: 'Adjust the playback style (web player only)',
|
||||||
isHidden: false,
|
isHidden: settings.type !== PlaybackType.WEB,
|
||||||
note:
|
note:
|
||||||
status === PlayerStatus.PLAYING ? 'Player must be paused' : undefined,
|
status === PlayerStatus.PLAYING ? 'Player must be paused' : undefined,
|
||||||
title: 'Playback style',
|
title: 'Playback style',
|
||||||
@@ -141,7 +174,7 @@ export const PlaybackTab = () => {
|
|||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
description: 'Adjust the crossfade duration (web player only)',
|
description: 'Adjust the crossfade duration (web player only)',
|
||||||
isHidden: false,
|
isHidden: settings.type !== PlaybackType.WEB,
|
||||||
note:
|
note:
|
||||||
status === PlayerStatus.PLAYING ? 'Player must be paused' : undefined,
|
status === PlayerStatus.PLAYING ? 'Player must be paused' : undefined,
|
||||||
title: 'Crossfade Duration',
|
title: 'Crossfade Duration',
|
||||||
@@ -179,7 +212,7 @@ export const PlaybackTab = () => {
|
|||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
description: 'Change the crossfade algorithm (web player only)',
|
description: 'Change the crossfade algorithm (web player only)',
|
||||||
isHidden: false,
|
isHidden: settings.type !== PlaybackType.WEB,
|
||||||
note:
|
note:
|
||||||
status === PlayerStatus.PLAYING ? 'Player must be paused' : undefined,
|
status === PlayerStatus.PLAYING ? 'Player must be paused' : undefined,
|
||||||
title: 'Crossfade Style',
|
title: 'Crossfade Style',
|
||||||
|
|||||||
Reference in New Issue
Block a user