From 77cd794b98ede903caa8e181fea39ba2d7eac5a9 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 21 Jul 2021 22:22:01 +0200 Subject: project file saving and loading :tada: --- pages/editor.tsx | 82 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 68 insertions(+), 14 deletions(-) (limited to 'pages') diff --git a/pages/editor.tsx b/pages/editor.tsx index 47402ec..115411f 100644 --- a/pages/editor.tsx +++ b/pages/editor.tsx @@ -8,6 +8,7 @@ import { v4 as uuid } from 'uuid'; import FadeThroughTransition from '../components/fadethrough'; import { + BracketsRoundedIcon, FullScreenControlsRoundedIcon, MenuBarControlsRoundedIcon, PressureIcon, @@ -60,7 +61,7 @@ import SettingsRoundedIcon from '@material-ui/icons/SettingsRounded'; import SkipPreviousRoundedIcon from '@material-ui/icons/SkipPreviousRounded'; import { mdiCursorDefault } from '@mdi/js'; -import CodeRoundedIcon from '@material-ui/icons/CodeRounded'; +import DescriptionRoundedIcon from '@material-ui/icons/DescriptionRounded'; import GetAppRoundedIcon from '@material-ui/icons/GetAppRounded'; import VideoLabelRoundedIcon from '@material-ui/icons/VideoLabelRounded'; @@ -68,6 +69,7 @@ var keyframeInAnimations: { [key: string]: { x: number; y: number; }; } = {}; var slideAPIs: { [key: string]: any; }[] = []; var player = new TimedVideoPlayer(); +var projectFile = new Project(); interface globalState { timeline: { @@ -1142,23 +1144,20 @@ function DefaultSettings() { { var file = event.target.files[0]; if (!file) return; var reader = new FileReader(); reader.addEventListener('load', ev => { - var proj = new Project(); - proj.video = new LocalVideo(); - proj.video.load(ev.target.result as ArrayBuffer); - // player.loadSlides(ev.target.result as string); - // project.timeline.set(player.timeline); - // global.timeline.workingTimeline.set(player.timeline.slides); - // global.update.refreshLiveTimeline.value(); - // global.ready.timeline.set(true); + player.loadSlides(ev.target.result as string); + project.timeline.set(player.timeline); + global.timeline.workingTimeline.set(player.timeline.slides); + global.update.refreshLiveTimeline.value(); + global.ready.timeline.set(true); }); - reader.readAsArrayBuffer(file); + reader.readAsText(file); }} />