From 9cf44906d3d20ef72379d36b7ccdc2241b1a17ff Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 24 Jul 2021 19:31:21 +0200 Subject: half load video on new project done --- components/videosourcesettings.tsx | 20 +++++++++++++++++--- pages/editor.tsx | 17 ++++++++++------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/components/videosourcesettings.tsx b/components/videosourcesettings.tsx index f4cea9e..35e180c 100644 --- a/components/videosourcesettings.tsx +++ b/components/videosourcesettings.tsx @@ -1,4 +1,6 @@ -import { useRef } from 'react'; +import { State } from '@hookstate/core'; +import { useRef, useState } from 'react'; +import { globalState } from '../pages/editor'; import { TimedVideoPlayer } from '../pages/present'; import { arrayBufferToBase64, LocalVideo } from '../project'; @@ -10,11 +12,15 @@ import { UploadRoundedIcon } from './icons'; type VideoSourceSettings = { settings: LocalVideo; player: TimedVideoPlayer; + global: State; }; export function LocalVideoSettings(props: VideoSourceSettings) { var fileUploadRef = useRef(null); + var [dummy, setDummy] = useState(false); + var rerender = () => setDummy(!dummy); + return <> { + reader.addEventListener('load', ev => { var video = ev.target.result as ArrayBuffer; props.settings.load(video); props.settings.mimetype = file.type; props.player.loadVideo(arrayBufferToBase64(video, file.type)); + props.global.update.refreshLiveTimeline.value(); + props.global.ready.video.set({ + available: true, + playable: true, + }); }); reader.readAsArrayBuffer(file); }} @@ -45,7 +56,10 @@ export function LocalVideoSettings(props: VideoSourceSettings) { Fully buffer video before presentation props.settings.config.fullyBuffer = !props.settings.config.fullyBuffer} + onChange={() => { + props.settings.config.fullyBuffer = !props.settings.config.fullyBuffer; + rerender(); + }} /> ; diff --git a/pages/editor.tsx b/pages/editor.tsx index f9c0e80..f07d915 100644 --- a/pages/editor.tsx +++ b/pages/editor.tsx @@ -63,7 +63,7 @@ var slideAPIs: { [key: string]: any; }[] = []; var player = new TimedVideoPlayer(); var projectFile = new Project(); -interface globalState { +export interface globalState { timeline: { playing: boolean; frame: number; @@ -1069,10 +1069,12 @@ function DefaultSettings() { Video source