revert to inline funcs

This commit is contained in:
Josh Hawkins 2024-07-04 17:38:57 -05:00
parent bdad02bff9
commit c79c631712

View File

@ -372,7 +372,13 @@ function MSEPlayer({
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [playbackEnabled]); }, [playbackEnabled]);
const handleLoadedData = useCallback(() => { return (
<video
ref={videoRef}
className={className}
playsInline
preload="auto"
onLoadedData={() => {
handleLoadedMetadata?.(); handleLoadedMetadata?.();
if (playTimeoutRef.current) { if (playTimeoutRef.current) {
clearTimeout(playTimeoutRef.current); clearTimeout(playTimeoutRef.current);
@ -380,12 +386,14 @@ function MSEPlayer({
} }
onPlaying?.(); onPlaying?.();
setIsPlaying(true); setIsPlaying(true);
}, [handleLoadedMetadata, onPlaying]); }}
muted={!audioEnabled}
const handleProgress = useCallback(() => { onPause={() => videoRef.current?.play()}
onProgress={() => {
if (!isPlaying && !playTimeoutRef.current && playbackEnabled) { if (!isPlaying && !playTimeoutRef.current && playbackEnabled) {
playTimeoutRef.current = setTimeout(() => { playTimeoutRef.current = setTimeout(() => {
handleLoadedData(); setIsPlaying(true);
onPlaying?.();
}, 5000); }, 5000);
} }
if (onError != undefined) { if (onError != undefined) {
@ -411,26 +419,7 @@ function MSEPlayer({
}, 3000), }, 3000),
); );
} }
}, [ }}
isPlaying,
onError,
videoRef,
bufferTimeout,
onDisconnect,
handleLoadedData,
playbackEnabled,
]);
return (
<video
ref={videoRef}
className={className}
playsInline
preload="auto"
onLoadedData={handleLoadedData}
muted={!audioEnabled}
onPause={() => videoRef.current?.play()}
onProgress={handleProgress}
onError={(e) => { onError={(e) => {
if ( if (
// @ts-expect-error code does exist // @ts-expect-error code does exist