From 3d396c2a11784a755fa96bb5031250c5d3d52e9e Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 25 Jul 2021 12:06:34 +0200 Subject: mostly working? --- pages/editor.tsx | 73 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 37 deletions(-) (limited to 'pages') diff --git a/pages/editor.tsx b/pages/editor.tsx index 1ae1587..c8de635 100644 --- a/pages/editor.tsx +++ b/pages/editor.tsx @@ -61,7 +61,8 @@ var keyframeInAnimations: { [key: string]: { x: number; y: number; }; } = {}; var slideAPIs: { [key: string]: any; }[] = []; var player = new TimedVideoPlayer(); -var projectFile = new Project(); +var project = new Project(); +player.project = project; export interface globalState { timeline: { @@ -140,7 +141,7 @@ var global = createState({ type: 'default', clickThroughBehaviour: 'ImmediatelySkip', }; - projectFile.timeline = player.timeline; + project.timeline = player.timeline; }, }, }); @@ -497,7 +498,7 @@ function TimelineSelection(props: { selectionDragArea: Ref; }) { selectionPosAPI.start({ visibility: 0 }); } else { var endingFrame = startingFrame + frameWidth; - var expandedTimeline = new Array(...projectFile.timeline); + var expandedTimeline = new Array(...project.timeline); for (let i = 0; i < expandedTimeline.length; i++) { var slide = expandedTimeline[i]; if (slide.type != 'loop') continue; @@ -656,7 +657,7 @@ function divs(int: number) { function getMarkerSpacing() { var zoom = global.timeline.zoom.value; var frameWidth = zoomToPx(zoom); - var divvable = divs(Math.round(projectFile?.video?.framerate)); + var divvable = divs(Math.round(project?.video?.framerate)); if (divvable.length == 0) return 30; var minSpacing = 120; var multiply = 1; @@ -709,7 +710,7 @@ function TimelineEditor() { useMousetrap(['.'], () => { // TODO: dry if (!global.ready.timeline.value) return; - var frame = Math.min(projectFile?.video?.framecount, global.timeline.frame.value + 1); + var frame = Math.min(project?.video?.framecount, global.timeline.frame.value + 1); global.timeline.frame.set(frame); scrubberSpring.start({ frame }); }); @@ -919,7 +920,7 @@ function TimelineEditor() {
{workingTimeline.map(slide => @@ -960,9 +961,9 @@ function DefaultSettings() {
Allow remote control during presentation { - projectFile.settings.remotes.AllowRemotes = !projectFile.settings.remotes.AllowRemotes; + project.settings.remotes.AllowRemotes = !project.settings.remotes.AllowRemotes; rerender(); }} /> @@ -970,9 +971,9 @@ function DefaultSettings() { On-screen controls { - projectFile.video = new (VideoSources.find(s => + project.video = new (VideoSources.find(s => s.type == e.target.value as VideoSourceType ).class)(); rerender(); @@ -1066,9 +1067,9 @@ function DefaultSettings() { {(() => { - if (!projectFile.video) return null; - var SourceSettings = VideoSources.find(s => s.type == projectFile.video.type).settings; - return ; + if (!project.video) return null; + var SourceSettings = VideoSources.find(s => s.type == project.video.type).settings; + return ; })()}
@@ -1076,9 +1077,9 @@ function DefaultSettings() {
Allow anonymous remotes { - projectFile.settings.remotes.AllowQRRemotes = !projectFile.settings.remotes.AllowQRRemotes; + project.settings.remotes.AllowQRRemotes = !project.settings.remotes.AllowQRRemotes; rerender(); }} /> @@ -1096,15 +1097,15 @@ function DefaultSettings() { if (!file) return; var reader = new FileReader(); reader.addEventListener('load', async ev => { - await projectFile.openProject(ev.target.result as ArrayBuffer); + await project.openProject(ev.target.result as ArrayBuffer); - player.loadSlides(projectFile.timeline); - projectFile.timeline = player.timeline; + player.loadSlides(project.timeline); + project.timeline = player.timeline; global.timeline.workingTimeline.set(player.timeline); global.update.refreshLiveTimeline.value(); global.ready.timeline.set(true); - player.loadVideo(arrayBufferToBase64(projectFile.video.source, projectFile.video.mimetype)); + player.loadVideo(arrayBufferToBase64(project.video.source, project.video.mimetype)); global.ready.video.available.set(true); player.player.addEventListener( @@ -1131,9 +1132,9 @@ function DefaultSettings() { children='Download .prspr' startIcon={} onClick={async () => { - projectFile.timeline = player.timeline; - projectFile.saveProject(); - projectFile.downloadProjectFile(); + project.timeline = player.timeline; + project.saveProject(); + project.downloadProjectFile(); }} />