mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-06 06:07:30 +00:00
fix(provider): make source optional
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ export const OmniProvider = ({
|
||||
showNotification = false,
|
||||
cast: _,
|
||||
}: {
|
||||
source: Source;
|
||||
source?: Source;
|
||||
cast?: CastOptions;
|
||||
children: ReactNode;
|
||||
showNotification?: boolean;
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user