From 2e6814caac72044da3aa476c7fa704b2fbfa7180 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 26 Jul 2021 09:03:36 +0200 Subject: /present uses new project file structure --- pages/present.tsx | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/pages/present.tsx b/pages/present.tsx index 09714a9..2757cc5 100644 --- a/pages/present.tsx +++ b/pages/present.tsx @@ -1,9 +1,10 @@ import Button from '@material-ui/core/Button'; import { useEffect, useState } from 'react'; import Timecode from 'timecode-boss'; -import Project from '../project'; +import Project, { arrayBufferToBase64 } from '../project'; import timeline, { delaySlide, loopSlide, slide, speedChangeSlide } from '../timeline'; +import DescriptionRoundedIcon from '@material-ui/icons/DescriptionRounded'; import ExitToAppRoundedIcon from '@material-ui/icons/ExitToAppRounded'; import PlayArrowRoundedIcon from '@material-ui/icons/PlayArrowRounded'; import SettingsRemoteRoundedIcon from '@material-ui/icons/SettingsRemoteRounded'; @@ -199,6 +200,8 @@ export default function Present() { var [dummy, setDummy] = useState(false); var rerender = () => setDummy(!dummy); var [player, _setPlayer] = useState(new TimedVideoPlayer()); + var [project, _setProject] = useState(new Project()); + player.project = project; useEffect(() => { setInterval(() => { @@ -231,6 +234,7 @@ export default function Present() { className='control menu' onClick={() => { document.getElementById('menu').classList.add('active'); + rerender(); }} />
+ { + var file = event.target.files[0]; + if (!file) return; + var reader = new FileReader(); + reader.addEventListener('load', async ev => { + await project.openProject(ev.target.result as ArrayBuffer); + + player.loadSlides(project.timeline); + player.loadVideo(arrayBufferToBase64(project.video.source, project.video.mimetype)); + + rerender(); + }); + reader.readAsArrayBuffer(file); + }} + /> +