From 647bf5d0badbe09002bb05a7c3a7c3fe316a62a1 Mon Sep 17 00:00:00 2001 From: der richter Date: Sun, 17 Mar 2024 17:51:05 +0100 Subject: mac/touchbar: take playback speed into account for rate limiting --- osdep/mac/touch_bar.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osdep/mac/touch_bar.swift b/osdep/mac/touch_bar.swift index dcebb24970..9ee312fa7a 100644 --- a/osdep/mac/touch_bar.swift +++ b/osdep/mac/touch_bar.swift @@ -80,6 +80,7 @@ class TouchBar: NSTouchBar, NSTouchBarDelegate { var isPaused: Bool = false var position: Double = 0 var duration: Double = 0 + var rate: Double = 0 override init() { super.init() @@ -326,7 +327,7 @@ class TouchBar: NSTouchBar, NSTouchBarDelegate { switch String(cString: property.name) { case "time-pos" where property.format == MPV_FORMAT_DOUBLE: let newPosition = max(LibmpvHelper.mpvDoubleToDouble(property.data) ?? 0, 0) - if Int(floor(newPosition) - floor(position)) != 0 { + if Int((floor(newPosition) - floor(position)) / rate) != 0 { position = newPosition updateTouchBarTimeItems() } @@ -336,6 +337,8 @@ class TouchBar: NSTouchBar, NSTouchBarDelegate { case "pause" where property.format == MPV_FORMAT_FLAG: isPaused = LibmpvHelper.mpvFlagToBool(property.data) ?? false updatePlayButton() + case "speed" where property.format == MPV_FORMAT_DOUBLE: + rate = LibmpvHelper.mpvDoubleToDouble(property.data) ?? 1 default: break } -- cgit v1.2.3