diff --git a/src/routes/_api/player/index.tsx b/src/routes/_api/player/index.tsx index c330b21..b091997 100644 --- a/src/routes/_api/player/index.tsx +++ b/src/routes/_api/player/index.tsx @@ -1,5 +1,9 @@ import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow"; -import React, { type ChangeEventHandler, useTransition } from "react"; +import React, { + type ChangeEventHandler, + type MouseEventHandler, + useTransition, +} from "react"; import { useLayoutEffect, useMemo } from "react"; import CircularProgress from "@mui/material/CircularProgress"; @@ -452,6 +456,13 @@ function VideoPlayer() { return marks; }, [item?.Chapters]); + const [showChapterList, setShowChapterList] = + useState(null); + const handleShowChapterList: MouseEventHandler = + useCallback((e) => { + setShowChapterList(e.currentTarget); + }, []); + const sliderDisplayFormat = (value: number) => { const currentChapter = item?.Chapters?.filter((chapter, index) => { if (index + 1 === item.Chapters?.length) { @@ -935,6 +946,38 @@ function VideoPlayer() { + + list + + setShowChapterList(null)} + anchorOrigin={{ + vertical: "top", + horizontal: "center", + }} + transformOrigin={{ + vertical: "bottom", + horizontal: "center", + }} + > + {chapterMarks && + item?.Chapters?.map((chapter) => ( + { + player.current?.seekTo( + ticksToSec(chapter.StartPositionTicks ?? 0), + "seconds", + ); + setShowChapterList(null); // Close the chapter list menu + }} + > + {chapter.Name} + + ))} +