mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 18:13:31 +00:00
feat: add audio channel configuration for MPV player
- Add audio channels setting (auto/mono/stereo) to MPV properties - Implement UI controls in settings panel and player right controls - Enable immediate MPV property application when setting changes - Update default playback type to LOCAL and sample rate to 48kHz
This commit is contained in:
parent
bf5e7bc774
commit
59e94318bb
6 changed files with 94 additions and 25 deletions
|
|
@ -36,6 +36,7 @@ import { PlaybackType } from '/@/shared/types/types';
|
|||
|
||||
const ipc = isElectron() ? window.api.ipc : null;
|
||||
const remote = isElectron() ? window.api.remote : null;
|
||||
const mpvPlayer = isElectron() ? window.api.mpvPlayer : null;
|
||||
|
||||
export const RightControls = () => {
|
||||
const { t } = useTranslation();
|
||||
|
|
@ -218,6 +219,46 @@ export const RightControls = () => {
|
|||
)}
|
||||
</Group>
|
||||
<Group align="center" gap="xs" wrap="nowrap">
|
||||
{(playbackType === PlaybackType.LOCAL || playbackType === PlaybackType.WEB) && (
|
||||
<ActionIcon
|
||||
icon={
|
||||
playbackSettings.mpvProperties.audioChannels === 'mono'
|
||||
? 'volumeNormal'
|
||||
: 'volumeMax'
|
||||
}
|
||||
iconProps={{
|
||||
size: 'lg',
|
||||
}}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
const current =
|
||||
playbackSettings.mpvProperties.audioChannels || 'stereo';
|
||||
const next = current === 'mono' ? 'stereo' : 'mono';
|
||||
setSettings({
|
||||
playback: {
|
||||
...playbackSettings,
|
||||
mpvProperties: {
|
||||
...playbackSettings.mpvProperties,
|
||||
audioChannels: next,
|
||||
},
|
||||
},
|
||||
});
|
||||
// Apply to MPV immediately
|
||||
mpvPlayer?.setProperties({
|
||||
'audio-channels': next,
|
||||
});
|
||||
}}
|
||||
size="sm"
|
||||
tooltip={{
|
||||
label:
|
||||
playbackType === PlaybackType.WEB
|
||||
? `Audio: ${playbackSettings.mpvProperties.audioChannels || 'stereo'} (MPV only)`
|
||||
: `Audio: ${playbackSettings.mpvProperties.audioChannels || 'stereo'}`,
|
||||
openDelay: 0,
|
||||
}}
|
||||
variant="subtle"
|
||||
/>
|
||||
)}
|
||||
<DropdownMenu arrowOffset={12} offset={0} position="top-end" width={425} withArrow>
|
||||
<DropdownMenu.Target>
|
||||
<ActionIcon
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ export const getMpvSetting = (
|
|||
value: any,
|
||||
) => {
|
||||
switch (key) {
|
||||
case 'audioChannels':
|
||||
return { 'audio-channels': value };
|
||||
case 'audioExclusiveMode':
|
||||
return { 'audio-exclusive': value || 'no' };
|
||||
case 'audioSampleRateHz':
|
||||
|
|
@ -53,6 +55,7 @@ export const getMpvSetting = (
|
|||
|
||||
export const getMpvProperties = (settings: SettingsState['playback']['mpvProperties']) => {
|
||||
const properties: Record<string, any> = {
|
||||
'audio-channels': settings.audioChannels || 'stereo',
|
||||
'audio-exclusive': settings.audioExclusiveMode || 'no',
|
||||
'audio-samplerate':
|
||||
settings.audioSampleRateHz === 0 ? undefined : settings.audioSampleRateHz,
|
||||
|
|
@ -271,6 +274,22 @@ export const MpvSettings = () => {
|
|||
isHidden: settings.type !== PlaybackType.LOCAL,
|
||||
title: t('setting.gaplessAudio', { postProcess: 'sentenceCase' }),
|
||||
},
|
||||
{
|
||||
control: (
|
||||
<Select
|
||||
data={[
|
||||
{ label: 'Mono', value: 'mono' },
|
||||
{ label: 'Stereo', value: 'stereo' },
|
||||
]}
|
||||
defaultValue={settings.mpvProperties.audioChannels || 'stereo'}
|
||||
onChange={(e) => handleSetMpvProperty('audioChannels', e)}
|
||||
/>
|
||||
),
|
||||
description:
|
||||
'Select the audio channel mode. Stereo is the default, mono downmixes to a single channel.',
|
||||
isHidden: settings.type !== PlaybackType.LOCAL,
|
||||
title: 'Audio Channels',
|
||||
},
|
||||
{
|
||||
control: (
|
||||
<NumberInput
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ const TranscodingConfigSchema = z.object({
|
|||
});
|
||||
|
||||
const MpvSettingsSchema = z.object({
|
||||
audioChannels: z.enum(['mono', 'stereo']).optional(),
|
||||
audioExclusiveMode: z.enum(['no', 'yes']),
|
||||
audioFormat: z.enum(['float', 's16', 's32']).optional(),
|
||||
audioSampleRateHz: z.number().optional(),
|
||||
|
|
@ -657,9 +658,10 @@ const initialState: SettingsState = {
|
|||
mediaSession: false,
|
||||
mpvExtraParameters: [],
|
||||
mpvProperties: {
|
||||
audioChannels: 'stereo',
|
||||
audioExclusiveMode: 'no',
|
||||
audioFormat: undefined,
|
||||
audioSampleRateHz: 0,
|
||||
audioSampleRateHz: 48000,
|
||||
gaplessAudio: 'weak',
|
||||
replayGainClip: true,
|
||||
replayGainFallbackDB: undefined,
|
||||
|
|
@ -678,7 +680,7 @@ const initialState: SettingsState = {
|
|||
transcode: {
|
||||
enabled: false,
|
||||
},
|
||||
type: PlaybackType.WEB,
|
||||
type: PlaybackType.LOCAL,
|
||||
webAudio: true,
|
||||
},
|
||||
remote: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue