Fix timed links resuming at watch position instead of URL timestamp

Timed links arrive wrapped as yattee://open?url=... from the share
extension, but the timestamp was parsed from the wrapper URL, where a
single-? form like youtu.be/ID?t=N hides t inside the url query item.
With no startTime the player fell back to saved watch progress.

- Add URLRouter.unwrapped(_:) resolving the wrapper to the inner URL
  (raw remainder after ?url=, since the share extension does not encode
  & and URLComponents would drop &t= parts) and use it in handleDeepLink
- Thread forceStartTime through openVideo/playPreferringDownloaded/play
  so explicit link timestamps beat the 90%-watched restart threshold,
  clamped to just before the end; resume flows keep the old behavior
- Carry the parsed timestamp through OpenLinkSheet's play action, which
  dropped it entirely
- Cover timestamp parsing and wrapper unwrapping in NavigationTests
This commit is contained in:
Arkadiusz Fal
2026-08-02 16:32:20 +02:00
parent b08974f4dc
commit d624a09335
5 changed files with 110 additions and 13 deletions

View File

@@ -682,7 +682,7 @@ struct OpenLinkFormView: View {
if !firstVideoPlayed {
// Play first video - this expands player
playVideo(video, appEnvironment: appEnvironment)
playVideo(video, sourceURL: url, appEnvironment: appEnvironment)
firstVideoPlayed = true
} else {
// Add to queue
@@ -767,11 +767,13 @@ struct OpenLinkFormView: View {
}
}
private func playVideo(_ video: Video, appEnvironment: AppEnvironment) {
private func playVideo(_ video: Video, sourceURL: URL, appEnvironment: AppEnvironment) {
// Don't pass a specific stream - let the player's selectStreamAndBackend
// choose the best video+audio combination. Using streams.first would
// incorrectly select audio-only streams for sites like Bilibili.
appEnvironment.playerService.openVideo(video)
let router = URLRouter()
let startTime = router.parseTimestamp(router.unwrapped(sourceURL))
appEnvironment.playerService.openVideo(video, startTime: startTime, forceStartTime: startTime != nil)
}
// MARK: - Download Action