mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-16 02:44:51 +00:00
fix(source): ensure object update doesn't reset player
This commit is contained in:
+11
-7
@@ -114,19 +114,23 @@ export const OmniView = ({
|
||||
false;
|
||||
const Tech = isHls ? HlsJsVideo : Video;
|
||||
|
||||
const config = useMemo<HlsMediaConfig | undefined>(() => {
|
||||
const headers = src?.headers;
|
||||
if (!headers || Object.keys(headers).length === 0) return undefined;
|
||||
return {
|
||||
const headersRef = useRef(src?.headers);
|
||||
headersRef.current = src?.headers;
|
||||
|
||||
const config = useMemo<HlsMediaConfig>(
|
||||
() => ({
|
||||
hlsJs: {
|
||||
xhrSetup: (xhr: XMLHttpRequest) => {
|
||||
const headers = headersRef.current;
|
||||
if (!headers) return;
|
||||
for (const [key, value] of Object.entries(headers)) {
|
||||
if (value) xhr.setRequestHeader(key, value);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}, [src?.headers]);
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
return (
|
||||
<VideoPlayer.Container
|
||||
@@ -137,7 +141,7 @@ export const OmniView = ({
|
||||
<Tech
|
||||
ref={ref}
|
||||
src={src.uri}
|
||||
config={config}
|
||||
config={isHls ? config : undefined}
|
||||
autoPlay={autoplay}
|
||||
playsInline
|
||||
crossOrigin="anonymous"
|
||||
|
||||
Reference in New Issue
Block a user