From e2d8e17f627da58b0c9f951cac0ff56b78b22812 Mon Sep 17 00:00:00 2001 From: goddonebianu Date: Sun, 8 Mar 2026 08:27:26 +0800 Subject: [PATCH] Sun Mar 8 08:27:26 AM CST 2026 --- AGENTS.md | 2 +- src/app/(features)/srt-player/page.tsx | 6 ++++-- src/app/(features)/srt-player/stores/videoStore.ts | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1ff66a5..54e4a14 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,7 +2,7 @@ ```bash # 使用以下命令检查代码合法性 -pnpm eslint +pnpm build ``` diff --git a/src/app/(features)/srt-player/page.tsx b/src/app/(features)/srt-player/page.tsx index 5337e8d..15dd3aa 100644 --- a/src/app/(features)/srt-player/page.tsx +++ b/src/app/(features)/srt-player/page.tsx @@ -12,7 +12,7 @@ import { getCurrentIndex } from "./subtitleParser"; export default function SRTPlayerPage() { const videoRef = useRef(null); - const { setVideoRef, currentSrc, loadVideo, loaded, getCurrentTime, getDuration, play, setOnTimeUpdate } = useVideoStore(); + const { setVideoRef, pause, currentSrc, isPlaying, loadVideo, loaded, getCurrentTime, getDuration, play, setOnTimeUpdate } = useVideoStore(); const { uploadVideo, uploadSubtitle, @@ -81,7 +81,9 @@ export default function SRTPlayerPage() { /* 控制面板 */ sub.length > 0 && loaded && - play + {isPlaying() ? + LightButton({ children: "pause", onClick: () => pause() }) : + LightButton({ children: "play", onClick: () => play() })} previous next restart diff --git a/src/app/(features)/srt-player/stores/videoStore.ts b/src/app/(features)/srt-player/stores/videoStore.ts index e148f99..6a5d79e 100644 --- a/src/app/(features)/srt-player/stores/videoStore.ts +++ b/src/app/(features)/srt-player/stores/videoStore.ts @@ -16,6 +16,7 @@ interface VideoStore { setVolume: (vol: number) => void; getCurrentTime: () => number | undefined; getDuration: () => number | undefined; + isPlaying: () => boolean; } export const useVideoStore = create()( @@ -102,5 +103,10 @@ export const useVideoStore = create()( }, getCurrentTime: () => get().videoRef?.current?.currentTime, getDuration: () => get().videoRef?.current?.duration, + isPlaying: () => { + const video = get().videoRef?.current; + if (!video) return false; + return !video.paused && !video.ended && video.readyState > 2; + } })) ); \ No newline at end of file