fix(playback): sync downloaded watch progress

close #1171, close #1183
This commit is contained in:
edde746
2026-05-29 19:55:01 +02:00
parent 5e5702c961
commit 7501f461b9
23 changed files with 418 additions and 69 deletions
@@ -22,9 +22,21 @@ extension _VideoPlayerPlaybackServiceMethods on VideoPlayerScreenState {
if (currentPlayer == null) return;
_stoppedProgressFuture = null;
// Progress tracker — offline mode queues for later sync; online mode
// dispatches to the right backend through the neutral client.
if (_isOfflinePlayback) {
// Progress tracker — local media still reports live when its server is
// online; only queue locally when no reporting client is reachable.
if (mediaClient != null) {
_progressTracker = PlaybackProgressTracker(
client: mediaClient,
metadata: metadata,
player: currentPlayer,
offlineWatchService: offlineWatchService,
queueOnOnlineFailure: _usesLocalPlaybackSource,
playMethod: playMethod ?? (_isTranscoding ? 'Transcode' : 'DirectPlay'),
playSessionId: playSessionId,
mediaInfo: mediaInfo,
);
_progressTracker!.startTracking();
} else if (_isOfflinePlayback) {
_progressTracker = PlaybackProgressTracker(
client: null,
metadata: metadata,
@@ -33,16 +45,6 @@ extension _VideoPlayerPlaybackServiceMethods on VideoPlayerScreenState {
offlineWatchService: offlineWatchService,
);
_progressTracker!.startTracking();
} else if (mediaClient != null) {
_progressTracker = PlaybackProgressTracker(
client: mediaClient,
metadata: metadata,
player: currentPlayer,
playMethod: playMethod ?? (_isTranscoding ? 'Transcode' : 'DirectPlay'),
playSessionId: playSessionId,
mediaInfo: mediaInfo,
);
_progressTracker!.startTracking();
}
// Media controls metadata. Fire-and-forget — the OS plugin downloads
@@ -78,10 +80,9 @@ extension _VideoPlayerPlaybackServiceMethods on VideoPlayerScreenState {
return;
}
// Get client (null in offline mode). Backend-neutral lookup so Jellyfin
// items also wire a [PlaybackProgressTracker]; the tracker dispatches
// to the right backend's reporting endpoints internally.
final mediaClient = _isOfflinePlayback ? null : _getMediaServerClient(context);
// Get a live reporting client when possible. Downloaded/local playback
// still uses this path when the server is reachable.
final mediaClient = _getOnlineMediaServerClient(context);
final offlineWatchService = context.read<OfflineWatchSyncService>();
// Initialize media controls manager (must exist before the per-item