feat(ui): add normalization toggle to player bar
Adds 3-state normalization icon between fullscreen and volume controls. Uses mask-image SVGs for theme-compatible coloring. Reduces song card min-width by 72px to accommodate the new control.
This commit is contained in:
1 parent
717eb6fed2
commit
00d0ce7835
9 files changed
+168
-7
No files matched your search
@@ -69,6 +69,9 @@
|
||||
onTrackClick?: () => void;
|
||||
onContextClick?: () => void;
|
||||
queueOpen?: boolean;
|
||||
normalizationEnabled?: boolean;
|
||||
normalizationGain?: number | null;
|
||||
onToggleNormalization?: () => void;
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -110,7 +113,10 @@
|
||||
onAlbumClick,
|
||||
onTrackClick,
|
||||
onContextClick,
|
||||
queueOpen = false
|
||||
queueOpen = false,
|
||||
normalizationEnabled = false,
|
||||
normalizationGain = null,
|
||||
onToggleNormalization
|
||||
}: Props = $props();
|
||||
|
||||
let progressRef: HTMLDivElement;
|
||||
@@ -382,6 +388,25 @@
|
||||
<Maximize2 size={16} />
|
||||
</button>
|
||||
|
||||
<!-- Normalization Toggle -->
|
||||
<button
|
||||
class="control-btn"
|
||||
class:active={normalizationEnabled && normalizationGain !== null && normalizationGain !== 1.0}
|
||||
class:norm-enabled={normalizationEnabled && (normalizationGain === null || normalizationGain === 1.0)}
|
||||
onclick={onToggleNormalization}
|
||||
title={!normalizationEnabled
|
||||
? $t('player.normalizationOff')
|
||||
: normalizationGain !== null && normalizationGain !== 1.0
|
||||
? $t('player.normalizationApplied')
|
||||
: $t('player.normalizationOn')}
|
||||
>
|
||||
<span
|
||||
class="norm-icon"
|
||||
class:norm-on={normalizationEnabled}
|
||||
aria-hidden="true"
|
||||
></span>
|
||||
</button>
|
||||
|
||||
<!-- Volume Control -->
|
||||
<div class="volume-control">
|
||||
<div class="volume-value" class:visible={isDraggingVolume}>{volume}</div>
|
||||
@@ -651,6 +676,31 @@
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
/* Normalization Icon (mask-image for currentColor inheritance) */
|
||||
.norm-icon {
|
||||
display: block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-color: currentColor;
|
||||
mask-image: url('/bars-disorder-outlined.svg');
|
||||
mask-size: contain;
|
||||
mask-repeat: no-repeat;
|
||||
mask-position: center;
|
||||
-webkit-mask-image: url('/bars-disorder-outlined.svg');
|
||||
-webkit-mask-size: contain;
|
||||
-webkit-mask-repeat: no-repeat;
|
||||
-webkit-mask-position: center;
|
||||
}
|
||||
|
||||
.norm-icon.norm-on {
|
||||
mask-image: url('/bars-normal.svg');
|
||||
-webkit-mask-image: url('/bars-normal.svg');
|
||||
}
|
||||
|
||||
.control-btn.norm-enabled {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.play-btn {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
@@ -670,7 +720,7 @@
|
||||
padding: 2px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: 8px;
|
||||
min-width: 580px;
|
||||
min-width: 508px;
|
||||
flex: 1;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
@@ -394,7 +394,10 @@
|
||||
"maximize": "Maximieren",
|
||||
"restore": "Wiederherstellen",
|
||||
"minimize": "Minimieren",
|
||||
"exitImmersive": "Immersiv-Modus beenden"
|
||||
"exitImmersive": "Immersiv-Modus beenden",
|
||||
"normalizationOff": "Lautstärkenormalisierung: Aus",
|
||||
"normalizationOn": "Lautstärkenormalisierung: Ein",
|
||||
"normalizationApplied": "Lautstärkenormalisierung: Aktiv"
|
||||
},
|
||||
"audioBadges": {
|
||||
"castingTo": "Übertragung an",
|
||||
|
||||
@@ -408,7 +408,10 @@
|
||||
"maximize": "Maximize",
|
||||
"restore": "Restore",
|
||||
"minimize": "Minimize",
|
||||
"exitImmersive": "Exit Immersive"
|
||||
"exitImmersive": "Exit Immersive",
|
||||
"normalizationOff": "Volume Normalization: Off",
|
||||
"normalizationOn": "Volume Normalization: On",
|
||||
"normalizationApplied": "Volume Normalization: Active"
|
||||
},
|
||||
"audioBadges": {
|
||||
"castingTo": "Casting to",
|
||||
|
||||
@@ -408,7 +408,10 @@
|
||||
"maximize": "Maximizar",
|
||||
"restore": "Restaurar",
|
||||
"minimize": "Minimizar",
|
||||
"exitImmersive": "Salir del modo inmersivo"
|
||||
"exitImmersive": "Salir del modo inmersivo",
|
||||
"normalizationOff": "Normalización de volumen: Desactivada",
|
||||
"normalizationOn": "Normalización de volumen: Activada",
|
||||
"normalizationApplied": "Normalización de volumen: Activa"
|
||||
},
|
||||
"audioBadges": {
|
||||
"castingTo": "Transmitiendo a",
|
||||
|
||||
@@ -394,7 +394,10 @@
|
||||
"maximize": "Agrandir",
|
||||
"restore": "Restaurer",
|
||||
"minimize": "Réduire",
|
||||
"exitImmersive": "Quitter le mode immersif"
|
||||
"exitImmersive": "Quitter le mode immersif",
|
||||
"normalizationOff": "Normalisation du volume : Désactivée",
|
||||
"normalizationOn": "Normalisation du volume : Activée",
|
||||
"normalizationApplied": "Normalisation du volume : Active"
|
||||
},
|
||||
"audioBadges": {
|
||||
"castingTo": "Diffusion vers",
|
||||
|
||||
@@ -76,6 +76,7 @@ interface PlaybackEvent {
|
||||
volume: number;
|
||||
sample_rate: number | null; // Actual stream sample rate in Hz
|
||||
bit_depth: number | null; // Actual stream bit depth
|
||||
normalization_gain: number | null; // Active normalization gain factor (null = not applied)
|
||||
}
|
||||
|
||||
// Queue track from backend (for external track sync)
|
||||
@@ -132,6 +133,7 @@ let castUnsubscribe: (() => void) | null = null;
|
||||
let isAdvancingTrack = false;
|
||||
let isSkipping = false;
|
||||
let queueEnded = false;
|
||||
let normalizationGain: number | null = null; // Current normalization gain (null = not active)
|
||||
|
||||
// Callbacks for track advancement (set by consumer)
|
||||
let onTrackEnded: (() => Promise<void>) | null = null;
|
||||
@@ -188,6 +190,10 @@ export function getIsSkipping(): boolean {
|
||||
return isSkipping;
|
||||
}
|
||||
|
||||
export function getNormalizationGain(): number | null {
|
||||
return normalizationGain;
|
||||
}
|
||||
|
||||
// ============ State Setter ============
|
||||
|
||||
export interface PlayerState {
|
||||
@@ -198,6 +204,7 @@ export interface PlayerState {
|
||||
volume: number;
|
||||
isFavorite: boolean;
|
||||
isSkipping: boolean;
|
||||
normalizationGain: number | null;
|
||||
}
|
||||
|
||||
export function getPlayerState(): PlayerState {
|
||||
@@ -208,7 +215,8 @@ export function getPlayerState(): PlayerState {
|
||||
duration,
|
||||
volume,
|
||||
isFavorite,
|
||||
isSkipping
|
||||
isSkipping,
|
||||
normalizationGain
|
||||
};
|
||||
}
|
||||
|
||||
@@ -547,6 +555,9 @@ async function handlePlaybackEvent(event: PlaybackEvent): Promise<void> {
|
||||
currentTrack.bitDepth = event.bit_depth;
|
||||
}
|
||||
|
||||
// Update normalization gain state
|
||||
normalizationGain = event.normalization_gain;
|
||||
|
||||
notifyListeners();
|
||||
|
||||
// Check if track ended - auto-advance to next
|
||||
|
||||
Reference in new issue
Block a user