fix(downloads): preserve audio track selection for offline playback

This commit is contained in:
Fredrik Burmester
2026-01-08 21:32:22 +01:00
parent 51ecde1565
commit d1387ec725
7 changed files with 146 additions and 6 deletions

View File

@@ -235,6 +235,9 @@ export function useDownloadEventHandlers({
trickPlayData,
introSegments,
creditSegments,
audioStreamIndex,
subtitleStreamIndex,
isTranscoding,
} = process;
const videoFile = new File(filePathToUri(event.filePath));
const fileInfo = videoFile.info();
@@ -258,8 +261,9 @@ export function useDownloadEventHandlers({
introSegments,
creditSegments,
userData: {
audioStreamIndex: 0,
subtitleStreamIndex: 0,
audioStreamIndex: audioStreamIndex ?? 0,
subtitleStreamIndex: subtitleStreamIndex ?? -1,
isTranscoded: isTranscoding ?? false,
},
};

View File

@@ -58,6 +58,8 @@ export function useDownloadOperations({
item: BaseItemDto,
mediaSource: MediaSourceInfo,
maxBitrate: Bitrate,
audioStreamIndex?: number,
subtitleStreamIndex?: number,
) => {
if (!api || !item.Id || !authHeader) {
console.warn("startBackgroundDownload ~ Missing required params");
@@ -114,6 +116,8 @@ export function useDownloadOperations({
trickPlayData: additionalAssets.trickPlayData,
introSegments: additionalAssets.introSegments,
creditSegments: additionalAssets.creditSegments,
audioStreamIndex,
subtitleStreamIndex,
};
// Add to processes

View File

@@ -21,6 +21,8 @@ interface UserData {
subtitleStreamIndex: number;
/** The last known audio stream index. */
audioStreamIndex: number;
/** Whether the downloaded file was transcoded (has only one audio track). */
isTranscoded: boolean;
}
/** Represents a segment of time in a media item, used for intro/credit skipping. */
@@ -142,4 +144,8 @@ export type JobStatus = {
introSegments?: MediaTimeSegment[];
/** Pre-downloaded credit segments (optional) - downloaded before video starts */
creditSegments?: MediaTimeSegment[];
/** The audio stream index selected for this download */
audioStreamIndex?: number;
/** The subtitle stream index selected for this download */
subtitleStreamIndex?: number;
};