Fix mpv sample rate setting

- Fix default input value
- Disable property on 0 value
This commit is contained in:
jeffvli 2023-05-17 17:25:20 -07:00
parent 48ef7a987f
commit e45252d16c
2 changed files with 10 additions and 8 deletions

View file

@ -43,7 +43,7 @@ export const getMpvSetting = (
export const getMpvProperties = (settings: SettingsState['playback']['mpvProperties']) => {
const properties: Record<string, any> = {
'audio-exclusive': settings.audioExclusiveMode || 'no',
'audio-samplerate': settings.audioSampleRateHz,
'audio-samplerate': settings.audioSampleRateHz === 0 ? undefined : settings.audioSampleRateHz,
'gapless-audio': settings.gaplessAudio || 'weak',
replaygain: settings.replayGainMode || 'no',
'replaygain-clip': settings.replayGainClip || 'no',
@ -182,17 +182,19 @@ export const MpvSettings = () => {
{
control: (
<NumberInput
defaultValue={settings.mpvProperties.replayGainPreampDB}
defaultValue={settings.mpvProperties.audioSampleRateHz}
width={100}
onBlur={(e) => handleSetMpvProperty('audioSampleRateHz', e.currentTarget.value)}
onBlur={(e) => {
const value = Number(e.currentTarget.value);
handleSetMpvProperty('audioSampleRateHz', value > 0 ? value : undefined);
}}
/>
),
description:
'Select the output sample rate to be used (of course sound cards have limits on this). If the sample frequency selected is different from that of the current media',
'Select the output sample rate to be used if the sample frequency selected is different from that of the current media',
isHidden: settings.type !== PlaybackType.LOCAL,
title: 'Sample rate',
},
{
control: (
<Switch

View file

@ -127,7 +127,7 @@ const initialState: SettingsState = {
fontContent: 'Poppins',
playButtonBehavior: Play.NOW,
showQueueDrawerButton: false,
sideQueueType: 'sideDrawerQueue',
sideQueueType: 'sideQueue',
skipButtons: {
enabled: false,
skipBackwardSeconds: 5,
@ -168,7 +168,7 @@ const initialState: SettingsState = {
mpvProperties: {
audioExclusiveMode: 'no',
audioFormat: undefined,
audioSampleRateHz: undefined,
audioSampleRateHz: 0,
gaplessAudio: 'weak',
replayGainClip: true,
replayGainFallbackDB: undefined,
@ -309,7 +309,7 @@ const initialState: SettingsState = {
disableAutoUpdate: false,
exitToTray: false,
minimizeToTray: false,
windowBarStyle: Platform.WEB,
windowBarStyle: isElectron() ? Platform.WINDOWS : Platform.WEB,
},
};