diff --git a/app/pages/PageEnigma/comps/ControlsVideo/ControlsVideo.tsx b/app/pages/PageEnigma/comps/ControlsVideo/ControlsVideo.tsx index 467e13f45c..7fc7e67d94 100644 --- a/app/pages/PageEnigma/comps/ControlsVideo/ControlsVideo.tsx +++ b/app/pages/PageEnigma/comps/ControlsVideo/ControlsVideo.tsx @@ -1,35 +1,57 @@ import { useContext } from "react"; +import { useSignals } from "@preact/signals-react/runtime"; import { faBackwardStep, faForwardStep, + faCirclePause, + faCirclePlay, faPlay, - faPause, } from "@fortawesome/pro-solid-svg-icons"; import { ButtonIcon } from "~/components"; import { EngineContext } from "~/pages/PageEnigma/contexts/EngineContext"; -import { currentTime, filmLength } from "~/pages/PageEnigma/signals"; +import { + currentTime, + filmLength, + scrubberTime, +} from "~/pages/PageEnigma/signals"; import Queue from "~/pages/PageEnigma/Queue/Queue"; import { QueueNames } from "~/pages/PageEnigma/Queue/QueueNames"; import { toEngineActions } from "~/pages/PageEnigma/Queue/toEngineActions"; -import { useSignals } from "@preact/signals-react/runtime"; import { editorState } from "~/pages/PageEnigma/signals/engine"; import { EditorStates } from "~/pages/PageEnigma/enums"; -// const SCALE_VALUES = [0.5, 1, 1.25, 1.5, 1.75, 2]; -// enum ScaleAdjustment { -// UP, -// DOWN, -// } - export const ControlsVideo = () => { useSignals(); const editorEngine = useContext(EngineContext); - // const scaleIndex = useRef(1); - // const canPlayback = editorEngine !== null && editorEngine.can_playback; - // console.log(`canplayback is ${canPlayback}`); + + function formatTime(seconds: number) { + const date = new Date(seconds * 1000); + const minutes = String(date.getUTCMinutes()).padStart(2, "0"); + const secs = String(date.getUTCSeconds()).padStart(2, "0"); + return `00:${minutes}:${secs}`; + } + const isPlaying = editorEngine !== null ? editorEngine.timeline.is_playing : false; + const handleToStart = () => { + currentTime.value = 0; + Queue.publish({ + queueName: QueueNames.TO_ENGINE, + action: toEngineActions.UPDATE_TIME, + data: { currentTime: currentTime.value }, + }); + }; + + const handleToEnd = () => { + currentTime.value = filmLength.value * 60; + Queue.publish({ + queueName: QueueNames.TO_ENGINE, + action: toEngineActions.UPDATE_TIME, + data: { currentTime: currentTime.value }, + }); + }; + const handleBackwardStep = () => { currentTime.value = Math.max(currentTime.value - 1, 0); Queue.publish({ @@ -55,24 +77,39 @@ export const ControlsVideo = () => { } return ( -