aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Foiani <sotech117@michaels-mbp-3.devices.brown.edu>2022-04-21 16:48:51 -0400
committerMichael Foiani <sotech117@michaels-mbp-3.devices.brown.edu>2022-04-21 16:48:51 -0400
commit0af393318adafa885d66c0fc43ffbf23f91e3c73 (patch)
tree3134ce352a8f48c3475b1aa7940a154d9f60fb14 /src
parentfd43ece4b97073b81553b5e8a8394d4404011005 (diff)
Integrate with jenny's videobox api
Diffstat (limited to 'src')
-rw-r--r--src/client/apis/recording/RecordingApi.ts (renamed from src/client/apis/recording/recordingApi.tsx)38
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx27
-rw-r--r--src/client/views/nodes/RecordingBox/RecordingView.tsx18
3 files changed, 33 insertions, 50 deletions
diff --git a/src/client/apis/recording/recordingApi.tsx b/src/client/apis/recording/RecordingApi.ts
index 97d4e2e7e..64243e443 100644
--- a/src/client/apis/recording/recordingApi.tsx
+++ b/src/client/apis/recording/RecordingApi.ts
@@ -1,7 +1,7 @@
import { CollectionFreeFormView } from "../../views/collections/collectionFreeForm";
import React, { useState } from "react";
-export function RecordingApi() {
+export namespace RecordingApi {
type Movement = {
time: number,
@@ -9,7 +9,7 @@ export function RecordingApi() {
panY: number,
}
- type Presentation = {
+ export type Presentation = {
movements: Array<Movement>
meta: Object,
startDate: Date | null,
@@ -25,7 +25,7 @@ export function RecordingApi() {
const [isRecording, setIsRecording] = useState(false)
const [absoluteStart, setAbsoluteStart] = useState<number>(-1)
- const initAndStart = (view: CollectionFreeFormView, meta?: Object): Error | undefined => {
+ export const initAndStart = (meta?: Object): Error | undefined => {
// check if already init a presentation
if (currentPresentation.startDate !== null) {
console.error('[recordingApi.ts] start() failed: current presentation data exists. please call clear() first.')
@@ -46,7 +46,7 @@ export function RecordingApi() {
setIsRecording(true)
}
- const clear = (): Error | undefined => {
+ export const clear = (): Error | undefined => {
// TODO: maybe archive the data?
if (isRecording) {
console.error('[recordingApi.ts] clear() failed: currently recording presentation. call pause() or finish() first')
@@ -55,17 +55,17 @@ export function RecordingApi() {
// clear presenation data
setCurrentPresenation(NULL_PRESENTATION)
- // clear isRecording
+ // set isRecording false
setIsRecording(false)
- // clear absoluteStart
+ // default absoluteStart
setAbsoluteStart(-1)
}
- const pause = (): Error | undefined => {
+ export const pause = (): Error | undefined => {
if (currentPresentation.startDate === null) {
console.error('[recordingApi.ts] pause() failed: no presentation started. try calling init() first')
- return new Error('[recordingApi.ts] pause(): no presenation')
+ return new Error('[recordingApi.ts] pause()')
}
// don't allow track movments
setIsRecording(false)
@@ -75,7 +75,7 @@ export function RecordingApi() {
setAbsoluteStart(timestamp)
}
- const resume = () => {
+ export const resume = () => {
if (currentPresentation.startDate === null) {
console.error('[recordingApi.ts] resume() failed: no presentation started. try calling init() first')
return new Error('[recordingApi.ts] resume()')
@@ -97,24 +97,26 @@ export function RecordingApi() {
})
}
- const finish = (): Error | Presentation => {
+ export const finish = (): Error | Presentation => {
if (currentPresentation.movements === null) {
console.error('[recordingApi.ts] finish() failed: no presentation data. try calling init() first')
return new Error('[recordingApi.ts] finish()')
}
// make copy and clear this class's data
- const returnCopy = { ...currentPresentation }
- clear()
+ // const returnCopy = { ...currentPresentation }
+ // clear()
+
+ // // return the copy
+ // return returnCopy
- // return the copy
- return returnCopy
+ return currentPresentation
}
- const trackMovements = (panX: number, panY: number): Error | undefined => {
+ export const trackMovements = (panX: number, panY: number): Error | undefined => {
// ensure we are recording
if (!isRecording) {
- console.error('[recordingApi.ts] pause() failed: recording is paused()')
+ console.error('[recordingApi.ts] pause() failed: recording is paused()')
return new Error('[recordingApi.ts] pause()')
}
@@ -134,7 +136,7 @@ export function RecordingApi() {
// TOOD: need to pause all intervals if possible lol
// TODO: extract this into different class with pause and resume recording
- const followMovements = (presentation: Presentation, docView: CollectionFreeFormView): void => {
+ export const followMovements = (presentation: Presentation, docView: CollectionFreeFormView): void => {
const document = docView.Document
const { movements } = presentation
@@ -148,6 +150,4 @@ export function RecordingApi() {
})
}
- return (<></>)
-
} \ No newline at end of file
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 6db2269c4..239aacd4f 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -51,6 +51,7 @@ import "./CollectionFreeFormView.scss";
import { MarqueeView } from "./MarqueeView";
import React = require("react");
import e = require("connect-flash");
+import { RecordingApi } from "../../../apis/recording/RecordingApi";
export const panZoomSchema = createSchema({
_panX: "number",
@@ -959,36 +960,18 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
}
}
-
- followMovements = (): void => {
- // need the first for subtraction
- let first = null;
-
- this.storedMovements.forEach(movement => {
- if (first === null) first = movement.time;
-
- // set the pan to what was stored
- setTimeout(() => {
- this.Document._panX = movement.panX;
- this.Document._panY = movement.panY;
- }, movement.time - first)
- })
-
- // for now, clear the movements
- this.storedMovements = []
- }
-
@action
setPan(panX: number, panY: number, panTime: number = 0, clamp: boolean = false) {
// if not presenting, just retrace the movements
if (Doc.UserDoc()?.presentationMode === 'watching') {
- this.followMovements()
- return;
+ // RecordingApi.followMovements(presentation, this)
+ return
}
if (Doc.UserDoc()?.presentationMode === 'recording') {
// store as many movments as possible
- this.storedMovements.push({time: new Date().getTime(), panX, panY})
+ // this.storedMovements.push({time: new Date().getTime(), panX, panY})
+ const err = RecordingApi.trackMovements(panX, panY)
}
if (!this.isAnnotationOverlay && clamp) {
diff --git a/src/client/views/nodes/RecordingBox/RecordingView.tsx b/src/client/views/nodes/RecordingBox/RecordingView.tsx
index 9be972d53..8c1ab9e2b 100644
--- a/src/client/views/nodes/RecordingBox/RecordingView.tsx
+++ b/src/client/views/nodes/RecordingBox/RecordingView.tsx
@@ -6,7 +6,7 @@ import { MdBackspace } from 'react-icons/md';
import { FaCheckCircle } from 'react-icons/fa';
import { IconContext } from "react-icons";
-import { RecordingApi } from '../../../apis/recording/recordingApi';
+import { RecordingApi } from '../../../apis/recording/RecordingApi';
enum RecordingStatus {
@@ -39,8 +39,6 @@ export function RecordingView() {
const videoElementRef = useRef<HTMLVideoElement | null>(null);
const [finished, setFinished] = useState<Boolean>(false)
-
- const recordingApiRef = useRef<any | null>(null);
@@ -75,7 +73,11 @@ export function RecordingView() {
videoElementRef.current!.srcObject = null
videoElementRef.current!.src = blobUrl
- videoElementRef.current!.muted = false
+ videoElementRef.current!.muted = false
+
+ // clear the recording api
+ const presentation = RecordingApi.finish()
+ RecordingApi.clear()
}
@@ -202,7 +204,8 @@ export function RecordingView() {
const pause = () => {
if (recorder.current) {
if (recorder.current.state === "recording") {
- recorder.current.pause();
+ recorder.current.pause();
+ const err = RecordingApi.pause()
}
}
}
@@ -211,7 +214,7 @@ export function RecordingView() {
console.log('[RecordingView.tsx] startOrResume')
if (!recorder.current || recorder.current.state === "inactive") {
record();
- recordingApiRef.current.startAndInit()
+ const err = RecordingApi.initAndStart()
} else if (recorder.current.state === "paused") {
recorder.current.resume();
}
@@ -325,9 +328,6 @@ export function RecordingView() {
)}
</button> */}
</div>
-
- <RecordingApi ref={recordingApiRef}></RecordingApi>
-
</div>
</div>)
} \ No newline at end of file