commit 2d4ddc7b9c0d65fcfdec37a839e96621f9cfec3c
parent 6003a3c6f809fcb0a4341b6302e92803a0693246
Author: Bryan Montz <bryanmontz@me.com>
Date: Sun, 25 Jun 2023 11:22:29 -0500
Fix crash related to VideoPlayer and CMTime
Closes: #1321
Changelog-Fixed: Fix crash related to VideoPlayer
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/damus/Views/Video/VideoPlayer.swift b/damus/Views/Video/VideoPlayer.swift
@@ -48,7 +48,8 @@ public class VideoPlayerModel: ObservableObject {
@Published var has_audio: Bool? = nil
@Published var contentMode: UIView.ContentMode = .scaleAspectFill
- var time: CMTime = CMTime()
+ fileprivate var time: CMTime?
+
var handlers: [VideoHandler] = []
init() {
@@ -262,8 +263,9 @@ extension VideoPlayer: UIViewRepresentable {
uiView.isMuted = model.muted
uiView.isAutoReplay = model.autoReplay
- if let observerTime = context.coordinator.observerTime, model.time != observerTime {
- uiView.seek(to: model.time, toleranceBefore: model.time, toleranceAfter: model.time, completion: { _ in })
+ if let observerTime = context.coordinator.observerTime, let modelTime = model.time,
+ modelTime != observerTime && modelTime.isValid && modelTime.isNumeric {
+ uiView.seek(to: modelTime, completion: { _ in })
}
}