Try to fix double load

This commit is contained in:
Ivan Malison 2024-10-17 18:34:34 -06:00
parent 7a1d0e8b10
commit 9138c3249d

View File

@ -267,14 +267,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
if (source?.cropEnd) { if (source?.cropEnd) {
shakaPlayerRef.current.configure({playRangeEnd: source?.cropEnd / 1000}) shakaPlayerRef.current.configure({playRangeEnd: source?.cropEnd / 1000})
} }
if (source?.cropStart) {
shakaPlayerRef.current.configure({playRangeStart: source?.cropStart / 1000})
}
if (source?.cropEnd) {
shakaPlayerRef.current.configure({playRangeEnd: source?.cropEnd / 1000})
}
//@ts-ignore
setCurrentSource(source);
//@ts-ignore //@ts-ignore
shakaPlayerRef.current.addEventListener("error", (event) => { shakaPlayerRef.current.addEventListener("error", (event) => {
//@ts-ignore //@ts-ignore
@ -287,6 +280,7 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
}, },
}); });
}); });
console.log("Initializing and attaching shaka") console.log("Initializing and attaching shaka")
//@ts-ignore //@ts-ignore
shakaPlayerRef.current.attach(nativeRef.current); shakaPlayerRef.current.attach(nativeRef.current);
@ -305,8 +299,10 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
console.log("Not starting shaka yet bc undefined") console.log("Not starting shaka yet bc undefined")
return; return;
} }
if (!shallowEqual(source, currentSource)) { if (!shallowEqual(source, currentSource)) {
console.log("Making new shaka, Old source: ", currentSource, "New source", source); console.log("Making new shaka, Old source: ", currentSource, "New source", source);
//@ts-ignore
setCurrentSource(source);
makeNewShaka() makeNewShaka()
} }
}, [source, nativeRefDefined, currentSource]) }, [source, nativeRefDefined, currentSource])