refactor: cleanup video player

This commit is contained in:
Prayag Prajapati committed 2024-12-09 23:38:40 +05:30
1 parent 9f7fde2173
commit bc6d39b004
1 file changed
+3 -3
+3 -3
View File
@@ -653,7 +653,7 @@ function VideoPlayer() {
}; };
const handlePrevChapter = useCallback(() => { const handlePrevChapter = useCallback(() => {
const chapters = item?.Chapters?.filter((chapter, index) => { const chapters = item?.Chapters?.filter((chapter) => {
if ((chapter.StartPositionTicks ?? 0) <= progress) { if ((chapter.StartPositionTicks ?? 0) <= progress) {
return true; return true;
} }
@@ -663,7 +663,7 @@ function VideoPlayer() {
} }
if (chapters?.length === 1) { if (chapters?.length === 1) {
player.current?.seekTo(ticksToSec(chapters[0].StartPositionTicks ?? 0)); player.current?.seekTo(ticksToSec(chapters[0].StartPositionTicks ?? 0));
} else if (chapters?.length > 1) { } else if ((chapters?.length ?? 0) > 1) {
player.current?.seekTo( player.current?.seekTo(
ticksToSec(chapters?.[chapters.length - 2].StartPositionTicks ?? 0), ticksToSec(chapters?.[chapters.length - 2].StartPositionTicks ?? 0),
); );
@@ -673,7 +673,7 @@ function VideoPlayer() {
// player.current?.seekTo(ticksToSec(currentChapter?.[0]?.StartPositionTicks ?? 0)); // player.current?.seekTo(ticksToSec(currentChapter?.[0]?.StartPositionTicks ?? 0));
}, [progress, playsessionId]); }, [progress, playsessionId]);
const handleNextChapter = useCallback(() => { const handleNextChapter = useCallback(() => {
const next = item?.Chapters?.filter((chapter, index) => { const next = item?.Chapters?.filter((chapter) => {
if ((chapter.StartPositionTicks ?? 0) > progress) { if ((chapter.StartPositionTicks ?? 0) > progress) {
return true; return true;
} }