feat: add compact progress decimal

This commit is contained in:
2026-10-17 18:26:39 +02:00
parent 117bf77902
commit 3368228537
4 changed files with 20 additions and 5 deletions
+3 -2
View File
@@ -33,9 +33,10 @@ struct SystemPlaybackChecks {
require(compactProgressText(position: position, duration: duration, format: .time) == expected,
"compact time uses total-duration units, truncation and bounded progress: \(expected)")
}
for (position, expected) in [(59.9, "59"), (100.0, "100"), (105.0, "100"), (-1.0, "0")] {
for (position, expected) in [(59.9, "59.9"), (59.99, "59.9"), (0.0, "0.0"),
(100.0, "100.0"), (105.0, "100.0"), (-1.0, "0.0")] {
require(compactProgressText(position: position, duration: 100, format: .percentage) == expected,
"compact percentage is a bounded integer: \(expected)")
"compact percentage has one decimal and stays bounded: \(expected)")
}
for duration in [0.0, -1.0, .nan, .infinity] {
require(compactProgressText(position: 10, duration: duration, format: .time) == nil &&
+1 -1
View File
@@ -112,7 +112,7 @@ automatic_quality = true
[ui]
buffer_info = true
compact_snap_to_edges = true
compact_title_progress = "percentage" # "time", "percentage", or "none"
compact_title_progress = "percentage" # "time", "percentage" (one decimal), or "none"
[keys]
play = "space"
+13 -1
View File
@@ -5,7 +5,10 @@ import TerebiConfiguration
func compactProgressText(position: Double, duration: Double, format: CompactTitleProgress) -> String? {
guard format != .none, duration.isFinite, duration > 0, position.isFinite else { return nil }
let position = min(max(0, position), duration)
if format == .percentage { return String(Int((position / duration * 100).rounded(.down))) }
if format == .percentage {
let tenths = Int((position / duration * 1000).rounded(.down))
return "\(tenths / 10).\(tenths % 10)"
}
let total = Int(min(duration, Double(Int.max / 2)))
let current = Int(min(position, Double(Int.max / 2)))
if duration < 60 { return "\(current) / \(total) s" }
@@ -1830,8 +1833,17 @@ private struct PlayerContent: View {
.frame(minWidth: 0, maxWidth: constrained ? .infinity : nil, alignment: .leading)
.clipped()
if let progress {
HStack(alignment: .center, spacing: 0) {
if model.compactTitleProgress == .percentage, let decimal = progress.firstIndex(of: ".") {
Text(" · \(progress[..<decimal])")
Text(String(progress[decimal...]))
.font(.system(size: 11 * 2 / 3, weight: .medium))
} else {
Text(" · \(progress)")
}
}
.monospacedDigit()
.accessibilityElement(children: .ignore)
.accessibilityLabel(model.compactTitleProgress == .percentage ? "\(progress) percent" : progress)
.fixedSize(horizontal: true, vertical: false)
}
+2
View File
@@ -1,5 +1,7 @@
- [x] improve chrome cast subtitle rendering
- native WebVTT style: white sans-serif, black outline, transparent background; physical-TV font-scale tuning remains unverified
- [ ] currently, computer falls asleep even if video is playing. this should not be the case.
- when casting, screensaver is ok, but the video stream should NOT be cut.
- [ ] add playlist support
- maybe by allowing multiple file selection? 🤔
- [ ] in the "choose what to play" screen, we should change the youtube button to general streaming