fix: don't crash app when no media source found for unmatched items

This commit is contained in:
Fredrik Burmester
2024-10-09 20:23:40 +02:00
parent 0a098bf26e
commit 39b7c66d34
2 changed files with 8 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ import { Settings } from "../atoms/settings";
interface PlaySettings {
item: BaseItemDto;
bitrate: (typeof BITRATES)[0];
mediaSource: MediaSourceInfo | undefined;
mediaSource?: MediaSourceInfo | null;
audioIndex?: number | null;
subtitleIndex?: number | null;
}
@@ -29,9 +29,8 @@ export function getDefaultPlaySettings(
}
// 1. Get first media source
const mediaSource = item.MediaSources?.[0];
if (!mediaSource) throw new Error("No media source found");
const mediaSource = item.MediaSources?.[0];
// 2. Get default or preferred audio
const defaultAudioIndex = mediaSource?.DefaultAudioStreamIndex;