From 5a66728480dcf9ea3281d1bd887f610f8e6b7db4 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 17 May 2021 11:15:52 +0200 Subject: timeline moves in editor to now --- pages/editor.tsx | 44 ++++++++++++++++++++++++++++++++------------ pages/present.tsx | 13 +++++++++---- 2 files changed, 41 insertions(+), 16 deletions(-) (limited to 'pages') diff --git a/pages/editor.tsx b/pages/editor.tsx index 4f49dbb..8bf757f 100644 --- a/pages/editor.tsx +++ b/pages/editor.tsx @@ -34,6 +34,11 @@ var useTimelineLabels = create(set => ({ setLabels: (newLabels: Array) => set(() => ({ labels: newLabels })), })); +var useFrame = create(set => ({ + currentFrame: 0, + setFrame: (newFrame: number) => set(() => ({ currentFrame: newFrame })), +})); + function TimelineEditor(props: { player: TimedVideoPlayer; }) { @@ -50,18 +55,26 @@ function TimelineEditor(props: { var timelineLabels = useTimelineLabels((st: any) => st.labels); var setTimelineLabels = useTimelineLabels((st: any) => st.setLabels); + var frame = useFrame((st: any) => st.currentFrame); + var setFrame = useFrame((st: any) => st.setFrame); + useEffect(() => { var canvas = document.getElementById('timeScaleCanvas') as HTMLCanvasElement; var ctx = canvas.getContext('2d'); - var mouseX = 0; - var mouseY = 0; + /* var mouseX = 0; */ + /* var mouseY = 0; */ - window.addEventListener('mousemove', e => { - var rect = canvas.getBoundingClientRect(); - mouseX = e.clientX - rect.x; - mouseY = e.clientY - rect.y; - }); + /* window.addEventListener('mousemove', e => { */ + /* var rect = canvas.getBoundingClientRect(); */ + /* mouseX = e.clientX - rect.x; */ + /* mouseY = e.clientY - rect.y; */ + /* }); */ + + function onframe(frame: number) { + setFrame(frame); + } + props.player.onframe = onframe; var css = (varname: string) => getComputedStyle(document.body).getPropertyValue(varname).trim(); var baseColor = css('--c100'); @@ -89,7 +102,7 @@ function TimelineEditor(props: { var rect = [Math.round(x + (frameWidth - 2) / 2), 28, 2, canvas.height]; var drawFrame = false; var marker = false; - if (frameWidth >= 3) { + if (frameWidth >= 6) { ctx.fillStyle = d ? baseColor : frameColor; rect = [x, 28, frameWidth, canvas.height]; drawFrame = !d; @@ -145,7 +158,7 @@ function TimelineEditor(props: {
{timelineLabels}
-
+
st.zoom); var setTimelineZoom = getTimelineZoom((st: any) => st.setZoom); + var frame = useFrame((st: any) => st.currentFrame); + useEffect(() => { var videoEL = document.getElementById('player') as HTMLVideoElement; player.registerPlayer(videoEL); @@ -255,8 +270,13 @@ export default function Index() {
} /> - } /> - } /> + } + onClick={() => player.next()} + /> + } onClick={() => player.previous()} /> } />
@@ -267,7 +287,7 @@ export default function Index() {
@{player.framerate}fps -

00:00:00:00f

+

{player.frameToTimestampString(frame, false)}