diff options
author | der richter <der.richter@gmx.de> | 2024-03-18 00:23:12 +0100 |
---|---|---|
committer | der richter <der.richter@gmx.de> | 2024-03-18 20:29:27 +0100 |
commit | 9f68214a06158387c6b8058752d060c12d75bbce (patch) | |
tree | 31765df704fbf8275bf5742e3a6815d833e49a99 | |
parent | d7cc5cdec14b943ad7009376291e6134d2370aab (diff) | |
download | mpv-9f68214a06158387c6b8058752d060c12d75bbce.tar.bz2 mpv-9f68214a06158387c6b8058752d060c12d75bbce.tar.xz |
mac/touchbar: optimise time item update
-rw-r--r-- | osdep/mac/touch_bar.swift | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/osdep/mac/touch_bar.swift b/osdep/mac/touch_bar.swift index 39aed1d35b..9bcd5540b7 100644 --- a/osdep/mac/touch_bar.swift +++ b/osdep/mac/touch_bar.swift @@ -77,9 +77,9 @@ extension TouchBar { class TouchBar: NSTouchBar, NSTouchBarDelegate { var configs: [NSTouchBarItem.Identifier:Config] = [:] - var isPaused: Bool = false - var position: Double = 0 - var duration: Double = 0 + var isPaused: Bool = false { didSet { updatePlayButton() } } + var position: Double = 0 { didSet { updateTouchBarTimeItems() } } + var duration: Double = 0 { didSet { updateTouchBarTimeItems() } } var rate: Double = 0 override init() { @@ -304,14 +304,11 @@ class TouchBar: NSTouchBar, NSTouchBarDelegate { let newPosition = max(LibmpvHelper.mpvDoubleToDouble(property.data) ?? 0, 0) if Int((floor(newPosition) - floor(position)) / rate) != 0 { position = newPosition - updateTouchBarTimeItems() } case "duration" where property.format == MPV_FORMAT_DOUBLE: duration = LibmpvHelper.mpvDoubleToDouble(property.data) ?? 0 - updateTouchBarTimeItems() 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: |