feat(ui): add stream first track toggle in settings
Add UI controls in SettingsView for streaming configuration: - Toggle for enabling stream-first mode for uncached tracks - Slider for initial buffer size (1-10 seconds) - Settings load/save handlers connected to Tauri commands - CSS styling for buffer slider cpvsc
This commit is contained in:
1 parent
1d0e069be1
commit
6e82fc380d
1 file changed
+87
@@ -248,6 +248,8 @@
|
|||||||
let selectedBackend = $state<string>('Auto');
|
let selectedBackend = $state<string>('Auto');
|
||||||
let selectedAlsaPlugin = $state<string>('hw (Direct Hardware)');
|
let selectedAlsaPlugin = $state<string>('hw (Direct Hardware)');
|
||||||
let alsaHardwareVolume = $state(false);
|
let alsaHardwareVolume = $state(false);
|
||||||
|
let streamFirstTrack = $state(false);
|
||||||
|
let streamBufferSeconds = $state(3);
|
||||||
|
|
||||||
// Backend system state
|
// Backend system state
|
||||||
let availableBackends = $state<BackendInfo[]>([]);
|
let availableBackends = $state<BackendInfo[]>([]);
|
||||||
@@ -886,6 +888,8 @@
|
|||||||
backend_type: 'PipeWire' | 'Alsa' | 'Pulse' | null;
|
backend_type: 'PipeWire' | 'Alsa' | 'Pulse' | null;
|
||||||
alsa_plugin: 'Hw' | 'PlugHw' | 'Pcm' | null;
|
alsa_plugin: 'Hw' | 'PlugHw' | 'Pcm' | null;
|
||||||
alsa_hardware_volume: boolean;
|
alsa_hardware_volume: boolean;
|
||||||
|
stream_first_track: boolean;
|
||||||
|
stream_buffer_seconds: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BackendInfo {
|
interface BackendInfo {
|
||||||
@@ -1031,6 +1035,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
alsaHardwareVolume = settings.alsa_hardware_volume ?? false;
|
alsaHardwareVolume = settings.alsa_hardware_volume ?? false;
|
||||||
|
streamFirstTrack = settings.stream_first_track ?? false;
|
||||||
|
streamBufferSeconds = settings.stream_buffer_seconds ?? 3;
|
||||||
|
|
||||||
// Validate mutual exclusion: DAC Passthrough disables Gapless + Crossfade
|
// Validate mutual exclusion: DAC Passthrough disables Gapless + Crossfade
|
||||||
if (dacPassthrough) {
|
if (dacPassthrough) {
|
||||||
@@ -1197,6 +1203,28 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleStreamFirstTrackChange(enabled: boolean) {
|
||||||
|
streamFirstTrack = enabled;
|
||||||
|
try {
|
||||||
|
await invoke('set_audio_stream_first_track', { enabled });
|
||||||
|
console.log('[Audio] Stream first track changed:', enabled);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[Audio] Failed to change stream first track:', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleStreamBufferSecondsChange(seconds: number) {
|
||||||
|
// Clamp to valid range
|
||||||
|
const clamped = Math.max(1, Math.min(10, Math.round(seconds)));
|
||||||
|
streamBufferSeconds = clamped;
|
||||||
|
try {
|
||||||
|
await invoke('set_audio_stream_buffer_seconds', { seconds: clamped });
|
||||||
|
console.log('[Audio] Stream buffer seconds changed:', clamped);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[Audio] Failed to change stream buffer seconds:', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function handleBackendDeviceChange(deviceName: string) {
|
async function handleBackendDeviceChange(deviceName: string) {
|
||||||
outputDevice = deviceName;
|
outputDevice = deviceName;
|
||||||
|
|
||||||
@@ -1651,6 +1679,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
<div class="setting-row">
|
||||||
|
<div class="setting-info">
|
||||||
|
<span class="setting-label">Stream Uncached Tracks</span>
|
||||||
|
<span class="setting-desc">Start playback faster when track is not in cache. Seeking may be limited during initial buffering.</span>
|
||||||
|
</div>
|
||||||
|
<Toggle enabled={streamFirstTrack} onchange={handleStreamFirstTrackChange} />
|
||||||
|
</div>
|
||||||
|
{#if streamFirstTrack}
|
||||||
|
<div class="setting-row">
|
||||||
|
<div class="setting-info">
|
||||||
|
<span class="setting-label">Initial Buffer Size</span>
|
||||||
|
<span class="setting-desc">Seconds to buffer before starting playback ({streamBufferSeconds}s)</span>
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
min="1"
|
||||||
|
max="10"
|
||||||
|
step="1"
|
||||||
|
value={streamBufferSeconds}
|
||||||
|
oninput={(e) => handleStreamBufferSecondsChange(parseInt(e.currentTarget.value))}
|
||||||
|
class="buffer-slider"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<div class="setting-row last">
|
<div class="setting-row last">
|
||||||
<span class="setting-label">{$t('settings.audio.currentSampleRate')}</span>
|
<span class="setting-label">{$t('settings.audio.currentSampleRate')}</span>
|
||||||
<span class="setting-value" class:muted={!hardwareStatus?.is_active}>
|
<span class="setting-value" class:muted={!hardwareStatus?.is_active}>
|
||||||
@@ -2896,6 +2948,41 @@ flatpak override --user --filesystem=$HOME/music-nas com.blitzfc.qbz</pre>
|
|||||||
color: rgb(251, 191, 36);
|
color: rgb(251, 191, 36);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Buffer slider styling */
|
||||||
|
.buffer-slider {
|
||||||
|
width: 120px;
|
||||||
|
height: 4px;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
background: var(--alpha-20);
|
||||||
|
border-radius: 2px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buffer-slider::-webkit-slider-thumb {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
background: var(--accent-color, #3b82f6);
|
||||||
|
border-radius: 50%;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: transform 0.1s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buffer-slider::-webkit-slider-thumb:hover {
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.buffer-slider::-moz-range-thumb {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
background: var(--accent-color, #3b82f6);
|
||||||
|
border-radius: 50%;
|
||||||
|
cursor: pointer;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<MigrationModal
|
<MigrationModal
|
||||||
|
|||||||
Reference in new issue
Block a user