just made the sora player support hours

This commit is contained in:
cranci1 2025-03-21 16:31:53 +01:00
parent baece1defd
commit d099267f6a
4 changed files with 18 additions and 11 deletions

View file

@ -20,11 +20,21 @@ extension Double {
}
extension BinaryFloatingPoint {
func asTimeString(style: DateComponentsFormatter.UnitsStyle) -> String {
let formatter = DateComponentsFormatter()
formatter.allowedUnits = [.minute, .second]
formatter.unitsStyle = style
formatter.zeroFormattingBehavior = .pad
return formatter.string(from: TimeInterval(self)) ?? ""
func asTimeString(style: TimeStringStyle, showHours: Bool = false) -> String {
let totalSeconds = Int(self)
let hours = totalSeconds / 3600
let minutes = (totalSeconds % 3600) / 60
let seconds = totalSeconds % 60
if showHours || hours > 0 {
return String(format: "%02d:%02d:%02d", hours, minutes, seconds)
} else {
return String(format: "%02d:%02d", minutes, seconds)
}
}
}
enum TimeStringStyle {
case positional
case standard
}

View file

@ -42,9 +42,9 @@ struct MusicProgressSlider<T: BinaryFloatingPoint>: View {
}
HStack {
Text(value.asTimeString(style: .positional))
Text(value.asTimeString(style: .positional, showHours: true))
Spacer(minLength: 0)
Text("-" + (inRange.upperBound - value).asTimeString(style: .positional))
Text("-" + (inRange.upperBound - value).asTimeString(style: .positional, showHours: true))
}
.font(.system(size: 12))
.foregroundColor(isActive ? fillColor : emptyColor)

View file

@ -700,7 +700,6 @@ class CustomMediaPlayerViewController: UIViewController {
self.subtitleLabel.text = ""
}
// ORIGINAL PROGRESS BAR CODE:
DispatchQueue.main.async {
self.sliderHostingController?.rootView = MusicProgressSlider(
value: Binding(get: { max(0, min(self.sliderViewModel.sliderValue, self.duration)) },

View file

@ -59,14 +59,12 @@ struct SettingsViewPlayer: View {
}
}
Section(header: Text("Skip Settings")) {
// Normal skip
HStack {
Text("Tap Skip:")
Spacer()
Stepper("\(Int(skipIncrement))s", value: $skipIncrement, in: 5...300, step: 5)
}
// Long-press skip
HStack {
Text("Long press Skip:")
Spacer()