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 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'components') 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(); + }} /> ; -- cgit v1.2.3