fix(provider): make source optional

This commit is contained in:
2026-07-21 19:50:30 +02:00
parent a335509b4e
commit 6eb02d32cb
17 changed files with 57 additions and 36 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ export const OmniProvider = ({
showNotification = false,
cast: _,
}: {
source: Source;
source?: Source;
cast?: CastOptions;
children: ReactNode;
showNotification?: boolean;
+5 -5
View File
@@ -22,7 +22,7 @@ export const OmniProvider = ({
cast,
showNotification = false,
}: {
source: Source;
source?: Source;
cast?: CastOptions;
children: ReactNode;
showNotification?: boolean;
@@ -47,7 +47,7 @@ const PlayerInitializer = ({
showNotification,
}: {
children: ReactNode;
source: Source;
source?: Source;
cast?: CastOptions;
showNotification: boolean;
}) => {
@@ -56,11 +56,11 @@ const PlayerInitializer = ({
const seekedForSrc = useRef<string | undefined>(undefined);
useEffect(() => {
player.source = source;
const uri = source.src[0]?.uri;
player.source = source ?? null;
const uri = source?.src[0]?.uri;
if (uri !== seekedForSrc.current) {
seekedForSrc.current = uri;
if (source.startTime) store.seek(source.startTime);
if (source?.startTime) store.seek(source.startTime);
}
}, [source, store]);
+2 -2
View File
@@ -57,9 +57,9 @@ export interface OmniPlayer
OmniPlayerT {
readonly eventMap: OmniEventMap;
setSource(src: Source): void;
setSource(src?: Source): void;
}
export interface OmniPlayerFactory extends HybridObject<{ android: "kotlin" }> {
createPlayer(props: Source): OmniPlayer;
createPlayer(props?: Source): OmniPlayer;
}