mirror of
https://github.com/yattee/yattee.git
synced 2026-05-12 10:25:02 +00:00
Resume and seek when reopening currently-loaded video
When the same video was already loaded (typically paused), opening it again via the URL scheme, a deep link, or a remote-control loadVideo command did nothing — the player just stayed paused. Now the same-video early-return path resumes playback if paused and seeks to the supplied startTime, so timestamps from URLs and remotes are honoured even when the video is already loaded. URLRouter gains a parseTimestamp helper that reads t/time/start query params in plain-seconds and YouTube-style (1h2m3s) forms, and the deep link handler now forwards that timestamp through to openVideo.
This commit is contained in:
@@ -916,12 +916,23 @@ final class PlayerService {
|
||||
let mpvPiPActive = false
|
||||
#endif
|
||||
|
||||
// If this video is already playing, just expand the player (unless PiP is active)
|
||||
// If this video is already loaded, optionally seek/resume instead of reloading.
|
||||
if isCurrentlyPlaying(video: video) {
|
||||
LoggingService.shared.logPlayer("Video already playing, just expanding")
|
||||
LoggingService.shared.logPlayer("Video already loaded, applying seek/resume instead of reload (startTime=\(startTime ?? -1), state=\(state.playbackState))")
|
||||
if !mpvPiPActive {
|
||||
navigationCoordinator?.expandPlayer()
|
||||
}
|
||||
let wasPaused = state.playbackState == .paused
|
||||
if let startTime {
|
||||
Task { @MainActor in
|
||||
await seek(to: startTime)
|
||||
if wasPaused || state.playbackState == .paused {
|
||||
resume()
|
||||
}
|
||||
}
|
||||
} else if wasPaused {
|
||||
resume()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -958,11 +969,14 @@ final class PlayerService {
|
||||
let mpvPiPActive = false
|
||||
#endif
|
||||
|
||||
// If this video is already playing, just expand the player (unless PiP is active)
|
||||
// If this video is already loaded, optionally resume instead of reloading.
|
||||
if isCurrentlyPlaying(video: video) {
|
||||
if !mpvPiPActive {
|
||||
navigationCoordinator?.expandPlayer()
|
||||
}
|
||||
if state.playbackState == .paused {
|
||||
resume()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user