diff --git a/package-lock.json b/package-lock.json
index 4d14ea6..30f2543 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -24,6 +24,7 @@
"@vaadin/vaadin-material-styles": "24.7.5",
"@vaadin/vaadin-themable-mixin": "24.7.5",
"@vaadin/vaadin-usage-statistics": "2.1.3",
+ "clsx": "^2.1.1",
"construct-style-sheets-polyfill": "3.1.0",
"date-fns": "2.29.3",
"lit": "3.3.0",
@@ -5560,9 +5561,9 @@
}
},
"node_modules/clsx": {
- "version": "1.2.1",
- "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz",
- "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
+ "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==",
"license": "MIT",
"engines": {
"node": ">=6"
@@ -8494,6 +8495,15 @@
"core-js": "^3.22.4"
}
},
+ "node_modules/react-range-slider-input/node_modules/clsx": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz",
+ "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/react-refresh": {
"version": "0.17.0",
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz",
diff --git a/package.json b/package.json
index 9a73bdb..66c4ae4 100644
--- a/package.json
+++ b/package.json
@@ -54,6 +54,7 @@
"@vaadin/vaadin-material-styles": "24.7.5",
"@vaadin/vaadin-themable-mixin": "24.7.5",
"@vaadin/vaadin-usage-statistics": "2.1.3",
+ "clsx": "^2.1.1",
"construct-style-sheets-polyfill": "3.1.0",
"date-fns": "2.29.3",
"lit": "3.3.0",
@@ -160,4 +161,4 @@
"react-slider": "$react-slider",
"lucide-react": "$lucide-react"
}
-}
\ No newline at end of file
+}
diff --git a/src/main/frontend/components/ClipRangeSlider.tsx b/src/main/frontend/components/ClipRangeSlider.tsx
new file mode 100644
index 0000000..807d273
--- /dev/null
+++ b/src/main/frontend/components/ClipRangeSlider.tsx
@@ -0,0 +1,40 @@
+import {VideoMetadata} from "Frontend/components/Playbar";
+import RangeSlider from 'react-range-slider-input';
+import 'react-range-slider-input/dist/style.css';
+import {useRef} from "react";
+import clsx from 'clsx';
+
+type Props = {
+ videoRef: HTMLVideoElement | null;
+ videoMetadata: VideoMetadata;
+ setSliderValue: Function;
+ className?: string;
+};
+
+export default function ClipRangeSlider({videoRef, videoMetadata, setSliderValue, className}: Props) {
+ const previousRangeSliderInput = useRef<[number, number]>([0, 0]);
+
+ const handleRangeSliderInput = (val: [number, number]) => {
+ if (!videoRef) return;
+
+ if (previousRangeSliderInput.current[0] != val[0]) {
+ videoRef.currentTime = val[0];
+ setSliderValue(val[0]);
+ } else if (previousRangeSliderInput.current[1] != val[1]) {
+ videoRef.currentTime = val[1];
+ setSliderValue(val[1]);
+ }
+
+ previousRangeSliderInput.current = val;
+ };
+
+ return (
+
+ )
+}
\ No newline at end of file
diff --git a/src/main/frontend/components/PlaybackSlider.tsx b/src/main/frontend/components/PlaybackSlider.tsx
new file mode 100644
index 0000000..c3db4d7
--- /dev/null
+++ b/src/main/frontend/components/PlaybackSlider.tsx
@@ -0,0 +1,51 @@
+import {VideoMetadata} from "Frontend/components/Playbar";
+import {useEffect, useState} from "react";
+import clsx from 'clsx';
+
+type Props = {
+ videoRef: HTMLVideoElement | null;
+ videoMetadata: VideoMetadata;
+ sliderValue: number;
+ setSliderValue: Function;
+ className?: string;
+};
+
+export default function PlaybackSlider({videoRef,
+ videoMetadata,
+ sliderValue,
+ setSliderValue,
+ className}: Props) {
+ const updateVideo = (e: React.ChangeEvent) => {
+ if (!videoRef) return;
+
+ videoRef.currentTime = e.target.valueAsNumber;
+ setSliderValue(e.target.valueAsNumber);
+ }
+
+ // update slider
+ useEffect(() => {
+ if (!videoRef) return;
+
+ const updateSlider = () => {
+ setSliderValue(videoRef.currentTime);
+ };
+
+ videoRef.addEventListener("timeupdate", updateSlider);
+
+ return () => {
+ videoRef.removeEventListener("timeupdate", updateSlider);
+ };
+ }, [videoRef]);
+
+ return (
+
+ )
+}
\ No newline at end of file
diff --git a/src/main/frontend/views/video/{id}.tsx b/src/main/frontend/views/video/{id}.tsx
index 327b2a8..882bbe9 100644
--- a/src/main/frontend/views/video/{id}.tsx
+++ b/src/main/frontend/views/video/{id}.tsx
@@ -1,42 +1,17 @@
import { useParams } from 'react-router-dom';
import { useEffect, useRef, useState } from "react";
-import RangeSlider from 'react-range-slider-input';
-import 'react-range-slider-input/dist/style.css';
-import Playbar, {VideoMetadata } from "./../../components/Playbar"
+import { VideoMetadata } from "Frontend/components/Playbar";
+import Playbar from "./../../components/Playbar"
+import PlaybackSlider from "./../../components/PlaybackSlider"
+import ClipRangeSlider from "./../../components/ClipRangeSlider"
export default function VideoId() {
const { id } = useParams();
const videoRef = useRef(null);
- const videoUrl = "api/v1/download/input/" + id;
+ const videoUrl = `api/v1/download/input/${id}`
const [metadata, setMetadata] = useState(null);
const [sliderValue, setSliderValue] = useState(0);
- const previousRangeSliderInput = useRef<[number, number]>([0, 0]);
-
- const handleRangeSliderInput = (val: [number, number]) => {
- if (!videoRef.current) {
- return;
- }
-
- if (previousRangeSliderInput.current[0] != val[0]) {
- videoRef.current.currentTime = val[0];
- setSliderValue(val[0]);
- } else if (previousRangeSliderInput.current[1] != val[1]) {
- videoRef.current.currentTime = val[1];
- setSliderValue(val[1]);
- }
-
- previousRangeSliderInput.current = val;
- };
-
- const updateVideoTag = (e: React.ChangeEvent) => {
- if (!videoRef.current) {
- return;
- }
-
- setSliderValue(parseFloat(e.target.value));
- videoRef.current.currentTime = parseFloat(e.target.value);
- };
useEffect(() => {
fetch(`api/v1/metadata/original/${id}`)
@@ -46,30 +21,13 @@ export default function VideoId() {
})
.then(setMetadata)
.catch((err) => console.log(err.message));
- }, []);
-
- // update slider
- useEffect(() => {
- const video = videoRef.current;
- if (!video) return;
-
- const updateSlider = () => {
- setSliderValue(video.currentTime);
- };
-
- video.addEventListener("timeupdate", updateSlider);
-
- return () => {
- video.removeEventListener("timeupdate", updateSlider);
- };
- }, [videoRef]);
+ }, [id]);
return (
-
+