refactor: migrate to react-player v3, fixing multiple instance of video player being created

This commit is contained in:
Prayag Prajapati committed 2025-07-01 21:46:23 +05:30
1 parent c69a547379
commit c4073f1368
9 files changed
+1080 -2297

No files matched your search

@@ -4,21 +4,27 @@ import { useShallow } from "zustand/shallow";
import { usePlaybackStore } from "@/utils/store/playback";
const SkipSegmentButton = () => {
const { mediaSegments, currentSegmentIndex, skipSegment } = usePlaybackStore(
useShallow((state) => ({
mediaSegments: state.metadata.mediaSegments,
currentSegmentIndex: state.nextSegmentIndex - 1,
skipSegment: state.skipSegment,
})),
);
const { mediaSegments, currentSegmentIndex, skipSegment, activeSegmentId } =
usePlaybackStore(
useShallow((state) => ({
mediaSegments: state.metadata.mediaSegments,
currentSegmentIndex: state.nextSegmentIndex - 1,
skipSegment: state.skipSegment,
activeSegmentId: state.activeSegmentId,
})),
);
if (!mediaSegments?.Items?.length || currentSegmentIndex < 0) {
console.info("Active segment ID:", activeSegmentId);
console.info("Current segment index:", currentSegmentIndex);
console.info("Media segments:", mediaSegments?.Items);
if (
!mediaSegments?.Items?.length ||
currentSegmentIndex < 0 ||
!activeSegmentId
) {
return <></>; // No segments to skip
}
console.log("Current Segment Index:", currentSegmentIndex);
console.log("Media Segments:", mediaSegments);
return (
<Button
variant="outlined"
@@ -38,4 +44,6 @@ const SkipSegmentButton = () => {
);
};
export default SkipSegmentButton;
const SkipSegmentButtonMemo = React.memo(SkipSegmentButton);
export default SkipSegmentButtonMemo;