Fix watched state update for both player styles

This commit is contained in:
MerlinScheurer
2025-01-29 20:10:20 +01:00
parent 4a67da12f7
commit d643e8c573
3 changed files with 12 additions and 8 deletions

View File

@@ -54,6 +54,7 @@ const handleTimeUpdate =
watched: boolean,
sponsorBlock?: SponsorBlockType,
setSponsorSegmentSkipped?: Dispatch<SetStateAction<SponsorSegmentsSkippedType>>,
onWatchStateChanged?: (status: boolean) => void,
) =>
async (videoTag: VideoTag) => {
const currentTime = Number(videoTag.currentTarget.currentTime);
@@ -93,6 +94,8 @@ const handleTimeUpdate =
id: youtubeId,
is_watched: true,
});
onWatchStateChanged?.(true);
}
}
}
@@ -103,6 +106,7 @@ type VideoPlayerProps = {
sponsorBlock?: SponsorBlockType;
embed?: boolean;
autoplay?: boolean;
onWatchStateChanged?: (status: boolean) => void;
onVideoEnd?: () => void;
};
@@ -111,6 +115,7 @@ const VideoPlayer = ({
sponsorBlock,
embed,
autoplay = false,
onWatchStateChanged,
onVideoEnd,
}: VideoPlayerProps) => {
const [searchParams] = useSearchParams();
@@ -182,6 +187,7 @@ const VideoPlayer = ({
watched,
sponsorBlock,
setSkippedSegments,
onWatchStateChanged,
)}
onPause={async (videoTag: VideoTag) => {
const currentTime = Number(videoTag.currentTarget.currentTime);