diff --git a/gui/src/components/commons/PausableVideo.tsx b/gui/src/components/commons/PausableVideo.tsx index ea6a3ff6e..9338bbd1c 100644 --- a/gui/src/components/commons/PausableVideo.tsx +++ b/gui/src/components/commons/PausableVideo.tsx @@ -1,16 +1,20 @@ import { useRef, useState } from 'react'; import { PlayCircleIcon } from './icon/PlayIcon'; import { useDebouncedEffect } from '@/hooks/timeout'; +import classNames from 'classnames'; export function PausableVideo({ src, poster, + restartOnPause = false, }: { src?: string; poster?: string; + restartOnPause?: boolean; }) { const videoRef = useRef(null); const [paused, setPaused] = useState(true); + const [atStart, setAtStart] = useState(true); function toggleVideo() { if (!videoRef.current) return; @@ -18,7 +22,10 @@ export function PausableVideo({ videoRef.current.play(); } else { videoRef.current.pause(); - videoRef.current.currentTime = 0; + if (restartOnPause) { + videoRef.current.currentTime = 0; + } + setAtStart(videoRef.current.currentTime === 0); } setPaused(videoRef.current.paused); } @@ -34,7 +41,11 @@ export function PausableVideo({ return (