fix(source): ensure object update doesn't reset player

This commit is contained in:
2026-07-16 12:27:50 +02:00
parent 61ee6238d5
commit 645b226359
3 changed files with 27 additions and 12 deletions
+11 -7
View File
@@ -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"