Add nil safety check for currentTime in MPVBackend

Added guard check to return early if currentTime is nil in getTimeUpdates. Simplified optional unwrapping by using the guarded currentTime value throughout the method.
This commit is contained in:
Arkadiusz Fal
2025-11-14 20:04:54 +01:00
parent a0a54bced9
commit 9d8fb0cfa2

View File

@@ -498,6 +498,10 @@ final class MPVBackend: PlayerBackend {
currentTime = client?.currentTime
playerItemDuration = client?.duration
guard let currentTime else {
return
}
if controlsUpdates {
updateControls()
}
@@ -505,16 +509,14 @@ final class MPVBackend: PlayerBackend {
model.updateNowPlayingInfo()
handleSegmentsThrottle.execute {
if let currentTime {
model.handleSegments(at: currentTime)
}
model.handleSegments(at: currentTime)
}
timeObserverThrottle.execute {
self.model.updateWatch(time: self.currentTime)
self.model.updateWatch(time: currentTime)
}
self.model.updateTime(self.currentTime!)
self.model.updateTime(currentTime)
}
private func stopClientUpdates() {