Compare commits

..

3 commits

Author SHA1 Message Date
8bc45cda3b
Update README.md
Some checks failed
Test / lint (push) Has been cancelled
2025-11-18 14:28:19 +00:00
e154810b21
Merge branch 'jeffvli:development' into development 2025-11-17 09:51:22 +02:00
0f22b9fbd7 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
2025-11-16 18:21:25 +02:00
3 changed files with 20 additions and 14 deletions

View file

@ -224,16 +224,22 @@ export const RightControls = () => {
icon={ icon={
playbackSettings.mpvProperties.audioChannels === 'mono' playbackSettings.mpvProperties.audioChannels === 'mono'
? 'volumeNormal' ? 'volumeNormal'
: 'volumeMax' : playbackSettings.mpvProperties.audioChannels === 'stereo'
? 'volumeMax'
: 'volumeMute'
} }
iconProps={{ iconProps={{
size: 'lg', size: 'lg',
}} }}
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
const current = const current = playbackSettings.mpvProperties.audioChannels || 'auto';
playbackSettings.mpvProperties.audioChannels || 'stereo'; const next =
const next = current === 'mono' ? 'stereo' : 'mono'; current === 'auto'
? 'mono'
: current === 'mono'
? 'stereo'
: 'auto';
setSettings({ setSettings({
playback: { playback: {
...playbackSettings, ...playbackSettings,
@ -245,15 +251,15 @@ export const RightControls = () => {
}); });
// Apply to MPV immediately // Apply to MPV immediately
mpvPlayer?.setProperties({ mpvPlayer?.setProperties({
'audio-channels': next, 'audio-channels': next === 'auto' ? undefined : next,
}); });
}} }}
size="sm" size="sm"
tooltip={{ tooltip={{
label: label:
playbackType === PlaybackType.WEB playbackType === PlaybackType.WEB
? `Audio: ${playbackSettings.mpvProperties.audioChannels || 'stereo'} (MPV only)` ? `Audio: ${playbackSettings.mpvProperties.audioChannels || 'auto'} (MPV only)`
: `Audio: ${playbackSettings.mpvProperties.audioChannels || 'stereo'}`, : `Audio: ${playbackSettings.mpvProperties.audioChannels || 'auto'}`,
openDelay: 0, openDelay: 0,
}} }}
variant="subtle" variant="subtle"

View file

@ -33,7 +33,7 @@ export const getMpvSetting = (
) => { ) => {
switch (key) { switch (key) {
case 'audioChannels': case 'audioChannels':
return { 'audio-channels': value }; return { 'audio-channels': value === 'auto' ? undefined : value };
case 'audioExclusiveMode': case 'audioExclusiveMode':
return { 'audio-exclusive': value || 'no' }; return { 'audio-exclusive': value || 'no' };
case 'audioSampleRateHz': case 'audioSampleRateHz':
@ -55,7 +55,7 @@ export const getMpvSetting = (
export const getMpvProperties = (settings: SettingsState['playback']['mpvProperties']) => { export const getMpvProperties = (settings: SettingsState['playback']['mpvProperties']) => {
const properties: Record<string, any> = { const properties: Record<string, any> = {
'audio-channels': settings.audioChannels || 'stereo', 'audio-channels': settings.audioChannels === 'auto' ? undefined : settings.audioChannels,
'audio-exclusive': settings.audioExclusiveMode || 'no', 'audio-exclusive': settings.audioExclusiveMode || 'no',
'audio-samplerate': 'audio-samplerate':
settings.audioSampleRateHz === 0 ? undefined : settings.audioSampleRateHz, settings.audioSampleRateHz === 0 ? undefined : settings.audioSampleRateHz,
@ -278,15 +278,15 @@ export const MpvSettings = () => {
control: ( control: (
<Select <Select
data={[ data={[
{ label: 'Auto', value: 'auto' },
{ label: 'Mono', value: 'mono' }, { label: 'Mono', value: 'mono' },
{ label: 'Stereo', value: 'stereo' }, { label: 'Stereo', value: 'stereo' },
]} ]}
defaultValue={settings.mpvProperties.audioChannels || 'stereo'} defaultValue={settings.mpvProperties.audioChannels || 'auto'}
onChange={(e) => handleSetMpvProperty('audioChannels', e)} onChange={(e) => handleSetMpvProperty('audioChannels', e)}
/> />
), ),
description: description: 'Select the audio channel mode. Auto lets MPV decide based on the source.',
'Select the audio channel mode. Stereo is the default, mono downmixes to a single channel.',
isHidden: settings.type !== PlaybackType.LOCAL, isHidden: settings.type !== PlaybackType.LOCAL,
title: 'Audio Channels', title: 'Audio Channels',
}, },

View file

@ -124,7 +124,7 @@ const TranscodingConfigSchema = z.object({
}); });
const MpvSettingsSchema = z.object({ const MpvSettingsSchema = z.object({
audioChannels: z.enum(['mono', 'stereo']).optional(), audioChannels: z.enum(['auto', 'mono', 'stereo']).optional(),
audioExclusiveMode: z.enum(['no', 'yes']), audioExclusiveMode: z.enum(['no', 'yes']),
audioFormat: z.enum(['float', 's16', 's32']).optional(), audioFormat: z.enum(['float', 's16', 's32']).optional(),
audioSampleRateHz: z.number().optional(), audioSampleRateHz: z.number().optional(),
@ -658,7 +658,7 @@ const initialState: SettingsState = {
mediaSession: false, mediaSession: false,
mpvExtraParameters: [], mpvExtraParameters: [],
mpvProperties: { mpvProperties: {
audioChannels: 'stereo', audioChannels: 'auto',
audioExclusiveMode: 'no', audioExclusiveMode: 'no',
audioFormat: undefined, audioFormat: undefined,
audioSampleRateHz: 48000, audioSampleRateHz: 48000,