From a4fb39a0d76757a0f63bd3994916e63368a97635 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Fri, 20 May 2022 23:20:18 +0200 Subject: [PATCH] Fix rate button --- Model/Player/Backends/MPVBackend.swift | 2 +- Shared/Player/Controls/PlayerControls.swift | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Model/Player/Backends/MPVBackend.swift b/Model/Player/Backends/MPVBackend.swift index eba076c1..7de798b8 100644 --- a/Model/Player/Backends/MPVBackend.swift +++ b/Model/Player/Backends/MPVBackend.swift @@ -217,7 +217,7 @@ final class MPVBackend: PlayerBackend { } func setRate(_ rate: Float) { - client.setDoubleAsync("speed", Double(rate)) + client?.setDoubleAsync("speed", Double(rate)) } func closeItem() {} diff --git a/Shared/Player/Controls/PlayerControls.swift b/Shared/Player/Controls/PlayerControls.swift index f2ff331f..04f74109 100644 --- a/Shared/Player/Controls/PlayerControls.swift +++ b/Shared/Player/Controls/PlayerControls.swift @@ -196,12 +196,12 @@ struct PlayerControls: View { #endif } - private var rateButton: some View { + @ViewBuilder private var rateButton: some View { #if os(macOS) ratePicker .labelsHidden() .frame(maxWidth: 70) - #else + #elseif os(iOS) Menu { ratePicker .frame(width: 45, height: 30) @@ -212,9 +212,16 @@ struct PlayerControls: View { } label: { Text(player.rateLabel(player.currentRate)) .foregroundColor(.primary) - .frame(maxWidth: .infinity) } - + .buttonStyle(.plain) + .foregroundColor(.primary) + .frame(width: 50, height: 30) + #if os(macOS) + .background(VisualEffectBlur(material: .hudWindow)) + #elseif os(iOS) + .background(VisualEffectBlur(blurStyle: .systemThinMaterial)) + #endif + .mask(RoundedRectangle(cornerRadius: 3)) #endif }