fix: skip offline video when different version requested

This commit is contained in:
edde746
2026-04-03 17:50:36 +02:00
parent d1d45c4998
commit dbb3e14c50
@@ -27,7 +27,7 @@ class PlaybackInitializationService {
///
/// Returns the local file path if the video is downloaded and completed.
/// Returns null if not available offline or database is not provided.
Future<String?> getOfflineVideoPath(String serverId, String ratingKey) async {
Future<String?> getOfflineVideoPath(String serverId, String ratingKey, {int mediaIndex = 0}) async {
if (database == null) {
return null;
}
@@ -44,6 +44,13 @@ class PlaybackInitializationService {
return null;
}
// Skip offline file if a different version was requested
if (downloadedItem.mediaIndex != mediaIndex) {
appLogger.d('[VersionTrace] Offline video is version ${downloadedItem.mediaIndex}, '
'but requested version $mediaIndex — skipping offline');
return null;
}
// Return null if no video file path
if (downloadedItem.videoFilePath == null) {
return null;
@@ -87,7 +94,7 @@ class PlaybackInitializationService {
// Check for offline content first if preferOffline is enabled
String? offlineVideoPath;
if (preferOffline && database != null) {
offlineVideoPath = await getOfflineVideoPath(client.serverId, metadata.ratingKey);
offlineVideoPath = await getOfflineVideoPath(client.serverId, metadata.ratingKey, mediaIndex: selectedMediaIndex);
}
// If offline video is available, use it