mirror of
https://github.com/yattee/yattee.git
synced 2026-05-12 18:35:05 +00:00
Suppress stale player error after switching videos mid-retry
If the MPV backend was retrying a failed load and the user switched to another video before retries exhausted, the eventual error was published to the player UI even though that video was no longer active. Guard the catch block with a loadingVideoID check so stale errors are dropped.
This commit is contained in:
@@ -498,6 +498,16 @@ final class PlayerService {
|
|||||||
LoggingService.shared.logPlayer("Playback cancelled: \(video.id.id)")
|
LoggingService.shared.logPlayer("Playback cancelled: \(video.id.id)")
|
||||||
sleepPreventionService.allowSleep()
|
sleepPreventionService.allowSleep()
|
||||||
} catch {
|
} catch {
|
||||||
|
// If the user has already switched to a different video while this one was
|
||||||
|
// still loading/retrying, suppress the error — it no longer applies to what
|
||||||
|
// is on screen. loadingVideoID is reassigned by every new play() call and
|
||||||
|
// cleared on success, so a mismatch means we are no longer the active load.
|
||||||
|
guard loadingVideoID == video.id else {
|
||||||
|
LoggingService.shared.logPlayer("Ignoring stale playback error for \(video.id.id) — user switched videos")
|
||||||
|
sleepPreventionService.allowSleep()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
LoggingService.shared.logPlayerError("Playback failed: \(video.id.id)", error: error)
|
LoggingService.shared.logPlayerError("Playback failed: \(video.id.id)", error: error)
|
||||||
sleepPreventionService.allowSleep()
|
sleepPreventionService.allowSleep()
|
||||||
state.videoDetailsState = .error
|
state.videoDetailsState = .error
|
||||||
|
|||||||
Reference in New Issue
Block a user