From def71ea56c99873af04dadc1c0e801d42c406826 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 24 Jul 2021 16:55:07 +0200 Subject: import net video saves in the cool new file format :tada: --- components/videosourcesettings.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'components') diff --git a/components/videosourcesettings.tsx b/components/videosourcesettings.tsx index ae7f75b..f4cea9e 100644 --- a/components/videosourcesettings.tsx +++ b/components/videosourcesettings.tsx @@ -1,12 +1,18 @@ import { useRef } from 'react'; -import { LocalVideo } from '../project'; +import { TimedVideoPlayer } from '../pages/present'; +import { arrayBufferToBase64, LocalVideo } from '../project'; import Button from '@material-ui/core/Button'; import Switch from '@material-ui/core/Switch'; import { UploadRoundedIcon } from './icons'; -export function LocalVideoSettings(props: { settings: LocalVideo; }) { +type VideoSourceSettings = { + settings: LocalVideo; + player: TimedVideoPlayer; +}; + +export function LocalVideoSettings(props: VideoSourceSettings) { var fileUploadRef = useRef(null); return <> @@ -20,7 +26,10 @@ export function LocalVideoSettings(props: { settings: LocalVideo; }) { if (!file) return; var reader = new FileReader(); reader.addEventListener('load', async ev => { - props.settings.load(ev.target.result as ArrayBuffer); + var video = ev.target.result as ArrayBuffer; + props.settings.load(video); + props.settings.mimetype = file.type; + props.player.loadVideo(arrayBufferToBase64(video, file.type)); }); reader.readAsArrayBuffer(file); }} -- cgit v1.2.3