Skip to content

Commit c00f8da

Browse files
committed
fix volume slider
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
1 parent e78b1cf commit c00f8da

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

Views/macOS/PlayerBar.swift

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ struct PlayerBar: View {
6565

6666
private var centerSection: some View {
6767
ZStack {
68-
// Track info (blurred when hovering)
68+
// Track info (blurred when hovering and track is playing)
6969
trackInfoView
70-
.blur(radius: isHovering ? 8 : 0)
71-
.opacity(isHovering ? 0 : 1)
70+
.blur(radius: isHovering && playerService.currentTrack != nil ? 8 : 0)
71+
.opacity(isHovering && playerService.currentTrack != nil ? 0 : 1)
7272

73-
// Seek bar (shown when hovering)
74-
if isHovering {
73+
// Seek bar (shown when hovering and track is playing)
74+
if isHovering, playerService.currentTrack != nil {
7575
seekBarView
7676
.transition(.opacity)
7777
}
@@ -92,8 +92,7 @@ struct PlayerBar: View {
9292
RoundedRectangle(cornerRadius: 4)
9393
.fill(.quaternary)
9494
.overlay {
95-
Image(systemName: "music.note")
96-
.font(.system(size: 12))
95+
CassetteIcon(size: 20)
9796
.foregroundStyle(.secondary)
9897
}
9998
}
@@ -277,19 +276,26 @@ struct PlayerBar: View {
277276
.foregroundStyle(.primary.opacity(0.6))
278277
.frame(width: 16)
279278

280-
// Volume slider with debounced updates
281-
Slider(value: $volumeValue, in: 0 ... 1)
282-
.frame(width: 80)
283-
.controlSize(.small)
284-
.onChange(of: volumeValue) { _, _ in
279+
// Volume slider with immediate updates
280+
Slider(value: $volumeValue, in: 0 ... 1) { editing in
281+
if editing {
282+
// User started dragging
285283
isAdjustingVolume = true
284+
} else {
285+
// User finished dragging - apply volume change
286+
performVolumeChange()
287+
}
288+
}
289+
.frame(width: 80)
290+
.controlSize(.small)
291+
.onChange(of: volumeValue) { _, newValue in
292+
// Apply volume changes in real-time during dragging for immediate feedback
293+
if isAdjustingVolume {
294+
Task {
295+
await playerService.setVolume(newValue)
296+
}
286297
}
287-
.simultaneousGesture(
288-
DragGesture(minimumDistance: 0)
289-
.onEnded { _ in
290-
performVolumeChange()
291-
}
292-
)
298+
}
293299
}
294300
}
295301

0 commit comments

Comments
 (0)