-
-
Notifications
You must be signed in to change notification settings - Fork 0
⌘R refresh + auto-retry on network loss for video playback #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -605,6 +605,42 @@ final class YouTubePlayerService { | |
| self.isPlaybackLoading = true | ||
| } | ||
|
|
||
| // MARK: - Refresh (⌘R) & network auto-retry | ||
|
|
||
| /// User-triggered refresh (⌘R): reloads the current video's playback surface | ||
| /// at its last position, to recover a stuck/black player after a network | ||
| /// interruption without losing the user's place. No-op when nothing is loaded. | ||
| /// | ||
| /// ponytail: a reload autoplays the watch page, so hitting this on a | ||
| /// deliberately-paused video resumes it — acceptable for a "refresh" action, | ||
| /// and the auto-retry path below only calls it when playback should be running. | ||
| func refreshCurrentVideo() { | ||
| guard let currentVideo = self.currentVideo else { return } | ||
| self.logger.info("Manual refresh: reloading current video") | ||
| self.beginYouTubePlaybackIntent() | ||
| let resumeAt = self.interruptionResumeAt(for: currentVideo.videoId) | ||
| self.playbackController.prepare( | ||
| webKitManager: self.webKitManager, | ||
| playerService: self, | ||
| usesCookieFreeDataStore: self.usesCookieFreePlaybackDataStore | ||
| ) | ||
| self.playbackController.reloadVideo(videoId: currentVideo.videoId, resumeAt: resumeAt) | ||
| self.isPlaybackLoading = true | ||
|
Comment on lines
+620
to
+628
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The refresh path starts a new autoplaying document without clearing Severity Level: Major
|
||
| } | ||
|
|
||
| /// Auto-retry when connectivity returns (issue #19): if a video was meant to | ||
| /// be playing but stalled during a network drop — still "loading", or not | ||
| /// playing while the user intends to — reload it. Deliberately-paused | ||
| /// playback is left alone so a network blip never yanks it back to life. | ||
| func handleNetworkRestored() { | ||
| guard self.currentVideo != nil else { return } | ||
| let stalled = self.isPlaybackLoading | ||
| || (self.desiredPlaybackIntent == .playing && !self.isPlaying) | ||
| guard stalled else { return } | ||
|
Comment on lines
+637
to
+639
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The loading-only branch ignores the user's playback intent. In particular, Severity Level: Major
|
||
| self.logger.info("Network restored: auto-reloading stalled video") | ||
| self.refreshCurrentVideo() | ||
| } | ||
|
|
||
| /// Returns the best native resume target for an interrupted document. | ||
| /// Native seek intent wins until the observer proves it was applied; | ||
| /// otherwise use the last genuine content clock. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: The new refresh command is always enabled and directly targets the YouTube service, unlike the existing video seek commands, which are disabled unless media keys are routed to video and a current video exists. When music is the active source but a YouTube video remains loaded in the background, ⌘R still reloads that video and can cause it to reclaim the playback arbiter, unexpectedly disrupting music. Apply the same active-video routing and availability guard used by the other video playback commands. [api mismatch]
Severity Level: Critical 🚨
Steps of Reproduction ✅
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖