Fix crash related to VideoPlayer and CMTime
Closes: #1321 Changelog-Fixed: Fix crash related to VideoPlayer
This commit is contained in:
committed by
William Casarin
parent
6003a3c6f8
commit
2d4ddc7b9c
@@ -48,7 +48,8 @@ public class VideoPlayerModel: ObservableObject {
|
|||||||
@Published var has_audio: Bool? = nil
|
@Published var has_audio: Bool? = nil
|
||||||
@Published var contentMode: UIView.ContentMode = .scaleAspectFill
|
@Published var contentMode: UIView.ContentMode = .scaleAspectFill
|
||||||
|
|
||||||
var time: CMTime = CMTime()
|
fileprivate var time: CMTime?
|
||||||
|
|
||||||
var handlers: [VideoHandler] = []
|
var handlers: [VideoHandler] = []
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@@ -262,8 +263,9 @@ extension VideoPlayer: UIViewRepresentable {
|
|||||||
uiView.isMuted = model.muted
|
uiView.isMuted = model.muted
|
||||||
uiView.isAutoReplay = model.autoReplay
|
uiView.isAutoReplay = model.autoReplay
|
||||||
|
|
||||||
if let observerTime = context.coordinator.observerTime, model.time != observerTime {
|
if let observerTime = context.coordinator.observerTime, let modelTime = model.time,
|
||||||
uiView.seek(to: model.time, toleranceBefore: model.time, toleranceAfter: model.time, completion: { _ in })
|
modelTime != observerTime && modelTime.isValid && modelTime.isNumeric {
|
||||||
|
uiView.seek(to: modelTime, completion: { _ in })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user