mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-01 19:48:28 +01:00
fix: don't crash app when no media source found for unmatched items
This commit is contained in:
@@ -26,7 +26,7 @@ import { useFocusEffect, useNavigation } from "expo-router";
|
|||||||
import * as ScreenOrientation from "expo-screen-orientation";
|
import * as ScreenOrientation from "expo-screen-orientation";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { View } from "react-native";
|
import { Alert, View } from "react-native";
|
||||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||||
import { Chromecast } from "./Chromecast";
|
import { Chromecast } from "./Chromecast";
|
||||||
import { ItemHeader } from "./ItemHeader";
|
import { ItemHeader } from "./ItemHeader";
|
||||||
@@ -59,6 +59,11 @@ export const ItemContent: React.FC<{ item: BaseItemDto }> = React.memo(
|
|||||||
audioIndex,
|
audioIndex,
|
||||||
subtitleIndex,
|
subtitleIndex,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!mediaSource) {
|
||||||
|
Alert.alert("Error", "No media source found for this item.");
|
||||||
|
navigation.goBack();
|
||||||
|
}
|
||||||
}, [item, settings])
|
}, [item, settings])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { Settings } from "../atoms/settings";
|
|||||||
interface PlaySettings {
|
interface PlaySettings {
|
||||||
item: BaseItemDto;
|
item: BaseItemDto;
|
||||||
bitrate: (typeof BITRATES)[0];
|
bitrate: (typeof BITRATES)[0];
|
||||||
mediaSource: MediaSourceInfo | undefined;
|
mediaSource?: MediaSourceInfo | null;
|
||||||
audioIndex?: number | null;
|
audioIndex?: number | null;
|
||||||
subtitleIndex?: number | null;
|
subtitleIndex?: number | null;
|
||||||
}
|
}
|
||||||
@@ -29,9 +29,8 @@ export function getDefaultPlaySettings(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1. Get first media source
|
// 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
|
// 2. Get default or preferred audio
|
||||||
const defaultAudioIndex = mediaSource?.DefaultAudioStreamIndex;
|
const defaultAudioIndex = mediaSource?.DefaultAudioStreamIndex;
|
||||||
|
|||||||
Reference in New Issue
Block a user