add stop button

This commit is contained in:
Armen Rohalov
2025-04-07 21:33:33 +03:00
parent 7b6149a33f
commit 4a33a47cf5
5 changed files with 50 additions and 9 deletions
+9
View File
@@ -18,6 +18,7 @@
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
"react-dropzone": "^14.3.8", "react-dropzone": "^14.3.8",
"react-icons": "^5.5.0",
"react-scripts": "5.0.1", "react-scripts": "5.0.1",
"web-vitals": "^2.1.4" "web-vitals": "^2.1.4"
} }
@@ -14371,6 +14372,14 @@
"integrity": "sha512-SN/U6Ytxf1QGkw/9ve5Y+NxBbZM6Ht95tuXNMKs8EJyFa/Vy/+Co3stop3KBHARfn/giv+Lj1uUnTfOJ3moFEQ==", "integrity": "sha512-SN/U6Ytxf1QGkw/9ve5Y+NxBbZM6Ht95tuXNMKs8EJyFa/Vy/+Co3stop3KBHARfn/giv+Lj1uUnTfOJ3moFEQ==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/react-icons": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.5.0.tgz",
"integrity": "sha512-MEFcXdkP3dLo8uumGI5xN3lDFNsRtrjbOEKDLD7yv76v4wpnEq2Lt2qeHaQOr34I/wPN3s3+N08WkQ+CW37Xiw==",
"peerDependencies": {
"react": "*"
}
},
"node_modules/react-is": { "node_modules/react-is": {
"version": "17.0.2", "version": "17.0.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
+1
View File
@@ -13,6 +13,7 @@
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
"react-dropzone": "^14.3.8", "react-dropzone": "^14.3.8",
"react-icons": "^5.5.0",
"react-scripts": "5.0.1", "react-scripts": "5.0.1",
"web-vitals": "^2.1.4" "web-vitals": "^2.1.4"
}, },
@@ -1,10 +1,10 @@
.input-group{ .input-group {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
padding: 0 4px; padding: 0 4px;
} }
.video-slider{ .video-slider {
width: 100%; width: 100%;
margin: 12px 20px; margin: 12px 20px;
} }
@@ -21,6 +21,9 @@
} }
.control-btn { .control-btn {
display: flex;
align-items: center;
gap: 4px;
padding: 10px 20px; padding: 10px 20px;
font-size: 16px; font-size: 16px;
margin: 0 5px; margin: 0 5px;
@@ -29,22 +32,26 @@
cursor: pointer; cursor: pointer;
} }
.play-btn{ .play-btn {
background: #8aff8a; background: #8aff8a;
} }
.pause-btn{ .pause-btn {
background: #ff8a8a; background: #ff8a8a;
} }
.arrow-btn{ .arrow-btn {
background: #e0e0e0; background: #e0e0e0;
} }
.save-btn{ .stop-btn {
background: #e8a1a5;
}
.save-btn {
background: #8ad4ff; background: #8ad4ff;
} }
.delete-btn{ .delete-btn {
background: #ffb38a; background: #ffb38a;
} }
@@ -1,7 +1,18 @@
import { Slider } from '@mui/material'; import { Slider } from '@mui/material';
import { FaStop } from "react-icons/fa";
import './AnnotationControls.css'; import './AnnotationControls.css';
function AnnotationControls({ videoRef, currentTime, setCurrentTime, onFrameBackward, onPlayPause, isPlaying, onFrameForward, onSaveAnnotation, onDelete }) { function AnnotationControls({
videoRef,
currentTime,
setCurrentTime,
onFrameBackward,
onPlayPause, isPlaying,
onFrameForward,
onSaveAnnotation,
onStop,
onDelete
}) {
function formatDuration(value) { function formatDuration(value) {
if (Number.isNaN(value)) { if (Number.isNaN(value)) {
@@ -57,6 +68,13 @@ function AnnotationControls({ videoRef, currentTime, setCurrentTime, onFrameBack
> >
</button> </button>
<button
className='control-btn stop-btn'
onClick={onStop}
title='Stop'
>
<FaStop /> Stop
</button>
<button <button
className='control-btn save-btn' className='control-btn save-btn'
onClick={onSaveAnnotation} onClick={onSaveAnnotation}
@@ -131,6 +131,11 @@ function AnnotationMain() {
}; };
const handleStop = () => {
setIsPlaying(prev => !prev);
setCurrentTime(0);
};
const handleFrameForward = () => { const handleFrameForward = () => {
if (videoRef.current) { if (videoRef.current) {
videoRef.current.currentTime += 1 / 30; videoRef.current.currentTime += 1 / 30;
@@ -220,6 +225,7 @@ function AnnotationMain() {
isPlaying={isPlaying} isPlaying={isPlaying}
onFrameForward={handleFrameForward} onFrameForward={handleFrameForward}
onSaveAnnotation={handleAnnotationSave} onSaveAnnotation={handleAnnotationSave}
onStop={handleStop}
onDelete={handleDelete} onDelete={handleDelete}
/> />
</div> </div>