diff options
author | lonkaars <loek@pipeframe.xyz> | 2021-07-24 16:55:07 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2021-07-24 16:55:07 +0200 |
commit | def71ea56c99873af04dadc1c0e801d42c406826 (patch) | |
tree | a083576cf451f6370c273d5d4586ac02aaa10998 /project.ts | |
parent | ff0609458ab50dd627b13b604f7c8c42af9a67b3 (diff) |
import net video saves in the cool new file format :tada:
Diffstat (limited to 'project.ts')
-rw-r--r-- | project.ts | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -1,5 +1,6 @@ import { MediaInfo as Mediainfo, ResultObject } from 'mediainfo.js/dist/types'; import JSZip from 'jszip'; +import semver from 'semver'; import { TimedVideoPlayer } from './pages/present'; import { LocalVideoSettings } from './components/videosourcesettings'; @@ -7,6 +8,13 @@ import { LocalVideoSettings } from './components/videosourcesettings'; // garbage garbage garbage declare var MediaInfo: () => Promise<Mediainfo>; +export function arrayBufferToBase64(buffer: ArrayBuffer, mimetype?: string) { + var out = ''; + if (mimetype) out += 'data:' + mimetype + ';base64,'; + out += btoa(new Uint8Array(buffer).reduce((data, byte) => data + String.fromCharCode(byte), '')); + return out; +} + const filext = '.prspr'; interface VideoSource { @@ -111,6 +119,8 @@ export default class { async openProject(data: ArrayBuffer) { this.zip = new JSZip(); await this.zip.loadAsync(data); + + this.version = await this.zip.file('meta/version').async('string'); this.project = { name: await this.zip.file('meta/name').async('string'), settings: { controlType: await this.zip.file('settings/controlType').async('string') }, @@ -118,11 +128,15 @@ export default class { framerate: Number(await this.zip.file('source/framerate').async('string')), framecount: Number(await this.zip.file('source/framecount').async('string')), } as TimedVideoPlayer['timeline']; + var type = await this.zip.file('source/type').async('string'); var videoSourceType = VideoSources.find(s => s.type == type); - if (!videoSourceType) return; + this.video = new videoSourceType.class(await this.zip.file('source/video').async('arraybuffer')); this.video.mimetype = await this.zip.file('source/mimetype').async('string'); - this.video.config = JSON.parse(await this.zip.file('source/config').async('string')); + + if (semver.lt('0.1.1', this.version)) { + this.video.config = JSON.parse(await this.zip.file('source/config').async('string')); + } } } |