Compare commits
3 Commits
613df6824b
...
e2d8e17f62
| Author | SHA1 | Date | |
|---|---|---|---|
| e2d8e17f62 | |||
| 63486757b9 | |||
| 45ffe5733b |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -51,4 +51,4 @@ test.js
|
|||||||
|
|
||||||
certificates
|
certificates
|
||||||
|
|
||||||
.claude
|
.opencode
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# CLAUDE.md
|
# AGENTS.md
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 使用以下命令检查代码合法性
|
# 使用以下命令检查代码合法性
|
||||||
pnpm eslint
|
pnpm build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ import { getCurrentIndex } from "./subtitleParser";
|
|||||||
|
|
||||||
export default function SRTPlayerPage() {
|
export default function SRTPlayerPage() {
|
||||||
const videoRef = useRef<HTMLVideoElement>(null);
|
const videoRef = useRef<HTMLVideoElement>(null);
|
||||||
const { setVideoRef, currentSrc, loadVideo, loaded, getCurrentTime, getDuration, play, setOnTimeUpdate } = useVideoStore();
|
const { setVideoRef, pause, currentSrc, isPlaying, loadVideo, loaded, getCurrentTime, getDuration, play, setOnTimeUpdate } = useVideoStore();
|
||||||
const {
|
const {
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
uploadSubtitle,
|
uploadSubtitle,
|
||||||
@@ -81,7 +81,9 @@ export default function SRTPlayerPage() {
|
|||||||
/* 控制面板 */
|
/* 控制面板 */
|
||||||
sub.length > 0 && loaded &&
|
sub.length > 0 && loaded &&
|
||||||
<HStack gap={2} className="mx-auto mt-4 w-[85%]" justify={"center"} wrap>
|
<HStack gap={2} className="mx-auto mt-4 w-[85%]" justify={"center"} wrap>
|
||||||
<LightButton onClick={play}>play</LightButton>
|
{isPlaying() ?
|
||||||
|
LightButton({ children: "pause", onClick: () => pause() }) :
|
||||||
|
LightButton({ children: "play", onClick: () => play() })}
|
||||||
<LightButton>previous</LightButton>
|
<LightButton>previous</LightButton>
|
||||||
<LightButton>next</LightButton>
|
<LightButton>next</LightButton>
|
||||||
<LightButton>restart</LightButton>
|
<LightButton>restart</LightButton>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ interface VideoStore {
|
|||||||
setVolume: (vol: number) => void;
|
setVolume: (vol: number) => void;
|
||||||
getCurrentTime: () => number | undefined;
|
getCurrentTime: () => number | undefined;
|
||||||
getDuration: () => number | undefined;
|
getDuration: () => number | undefined;
|
||||||
|
isPlaying: () => boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useVideoStore = create<VideoStore>()(
|
export const useVideoStore = create<VideoStore>()(
|
||||||
@@ -102,5 +103,10 @@ export const useVideoStore = create<VideoStore>()(
|
|||||||
},
|
},
|
||||||
getCurrentTime: () => get().videoRef?.current?.currentTime,
|
getCurrentTime: () => get().videoRef?.current?.currentTime,
|
||||||
getDuration: () => get().videoRef?.current?.duration,
|
getDuration: () => get().videoRef?.current?.duration,
|
||||||
|
isPlaying: () => {
|
||||||
|
const video = get().videoRef?.current;
|
||||||
|
if (!video) return false;
|
||||||
|
return !video.paused && !video.ended && video.readyState > 2;
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
Reference in New Issue
Block a user