fixed many things
Some checks are pending
Build and Release / Build IPA (push) Waiting to run
Build and Release / Build Mac Catalyst (push) Waiting to run

This commit is contained in:
cranci1 2025-07-14 11:51:48 +02:00
parent d6c6e4a1aa
commit 1603c6df8c
5 changed files with 57 additions and 8 deletions

View file

@ -632,6 +632,7 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
NotificationCenter.default.addObserver(self, selector: #selector(playerItemDidChange), name: .AVPlayerItemNewAccessLogEntry, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(subtitleSettingsDidChange), name: .subtitleSettingsDidChange, object: nil)
skip85Button?.isHidden = !isSkip85Visible
if !isSkip85Visible {
skip85Button?.alpha = 0.0
@ -782,6 +783,15 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
}
}
@objc private func subtitleSettingsDidChange() {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
self.loadSubtitleSettings()
self.updateSubtitleLabelAppearance()
self.updateSubtitleLabelConstraints()
}
}
private func getSegmentsColor() -> Color {
if let data = UserDefaults.standard.data(forKey: "segmentsColorData"),
let uiColor = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? UIColor {

View file

@ -7,6 +7,10 @@
import UIKit
extension Notification.Name {
static let subtitleSettingsDidChange = Notification.Name("subtitleSettingsDidChange")
}
struct SubtitleSettings: Codable {
var enabled: Bool = true
var foregroundColor: String = "white"
@ -33,6 +37,7 @@ class SubtitleSettingsManager {
set {
if let data = try? JSONEncoder().encode(newValue) {
UserDefaults.standard.set(data, forKey: userDefaultsKey)
NotificationCenter.default.post(name: .subtitleSettingsDidChange, object: nil)
}
}
}

View file

@ -88,16 +88,14 @@ class VTTSubtitlesLoader: ObservableObject {
}
let startTime = parseTimecode(times[0].trimmingCharacters(in: .whitespaces))
let adjustedStartTime = max(startTime - 0.5, 0)
let endTime = parseTimecode(times[1].trimmingCharacters(in: .whitespaces))
let adjusteEndTime = max(endTime - 0.5, 0)
index += 1
var cueText = ""
while index < lines.count && !lines[index].trimmingCharacters(in: .whitespaces).isEmpty {
cueText += lines[index] + "\n"
index += 1
}
cues.append(SubtitleCue(startTime: adjustedStartTime, endTime: adjusteEndTime, text: cueText.trimmingCharacters(in: .whitespacesAndNewlines)))
cues.append(SubtitleCue(startTime: startTime, endTime: endTime, text: cueText.trimmingCharacters(in: .whitespacesAndNewlines)))
}
return cues
}
@ -118,9 +116,7 @@ class VTTSubtitlesLoader: ObservableObject {
guard times.count >= 2 else { continue }
let startTime = parseSRTTimecode(times[0].trimmingCharacters(in: .whitespaces))
let adjustedStartTime = max(startTime - 0.5, 0)
let endTime = parseSRTTimecode(times[1].trimmingCharacters(in: .whitespaces))
let adjustedEndTime = max(endTime - 0.5, 0)
var textLines = [String]()
if lines.count > 2 {
@ -128,7 +124,7 @@ class VTTSubtitlesLoader: ObservableObject {
}
let text = textLines.joined(separator: "\n")
cues.append(SubtitleCue(startTime: adjustedStartTime, endTime: adjustedEndTime, text: text))
cues.append(SubtitleCue(startTime: startTime, endTime: endTime, text: text))
}
return cues

View file

@ -202,6 +202,7 @@ struct MediaInfoView: View {
activeFetchID = nil
UserDefaults.standard.set(false, forKey: "isMediaInfoActive")
UIScrollView.appearance().bounces = true
NotificationCenter.default.post(name: .showTabBar, object: nil)
}
.task {
await setupInitialData()

View file

@ -304,6 +304,29 @@ struct SettingsViewPlayer: View {
)
}
SettingsSection(title: NSLocalizedString("Progress bar Marker Color", comment: "")) {
ColorPicker(NSLocalizedString("Segments Color", comment: ""), selection: Binding(
get: {
if let data = UserDefaults.standard.data(forKey: "segmentsColorData"),
let uiColor = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? UIColor {
return Color(uiColor)
}
return .yellow
},
set: { newColor in
let uiColor = UIColor(newColor)
if let data = try? NSKeyedArchiver.archivedData(
withRootObject: uiColor,
requiringSecureCoding: false
) {
UserDefaults.standard.set(data, forKey: "segmentsColorData")
}
}
))
.padding(.horizontal, 16)
.padding(.vertical, 12)
}
SettingsSection(
title: NSLocalizedString("Skip Settings", comment: ""),
footer: NSLocalizedString("Double tapping the screen on it's sides will skip with the short tap setting.", comment: "")
@ -439,14 +462,28 @@ struct SubtitleSettingsSection: View {
title: NSLocalizedString("Bottom Padding", comment: ""),
value: $bottomPadding,
range: 0...50,
step: 1,
showDivider: false
step: 1
)
.onChange(of: bottomPadding) { newValue in
SubtitleSettingsManager.shared.update { settings in
settings.bottomPadding = CGFloat(newValue)
}
}
SettingsStepperRow(
icon: "clock",
title: NSLocalizedString("Subtitle Delay", comment: ""),
value: $subtitleDelay,
range: -10...10,
step: 0.1,
formatter: { String(format: "%.1fs", $0) },
showDivider: false
)
.onChange(of: subtitleDelay) { newValue in
SubtitleSettingsManager.shared.update { settings in
settings.subtitleDelay = newValue
}
}
}
}
}