diff options
Diffstat (limited to 'src/client/util/RecordingApi.ts')
-rw-r--r-- | src/client/util/RecordingApi.ts | 70 |
1 files changed, 30 insertions, 40 deletions
diff --git a/src/client/util/RecordingApi.ts b/src/client/util/RecordingApi.ts index 009652f6e..12c1654a2 100644 --- a/src/client/util/RecordingApi.ts +++ b/src/client/util/RecordingApi.ts @@ -58,13 +58,7 @@ export class RecordingApi { } public start = (meta?: Object) => { - // check if already init a presentation - if (!this.isInitPresenation) { - console.log(this.currentPresentation) - console.trace('[recordingApi.ts] start() failed: current presentation data exists. please call clear() first.') - } - - // update the presentation mode + // update the presentation mode Doc.UserDoc().presentationMode = 'recording'; // (1a) get start date for presenation @@ -81,12 +75,10 @@ export class RecordingApi { } /* stops the video and returns the presentatation; if no presentation, returns undefined */ - public* yieldPresentation(clearData: boolean = true): Generator<Presentation | null> { - // TODO: maybe archive the data? - // if (this.tracking) console.warn('[recordingApi.ts] getPresentation() : currently recording presentation.'); + public * yieldPresentation(clearData: boolean = true): Generator<Presentation | null> { + // if no presentation or done tracking, return null + if (!this.isInitPresenation || !this.tracking) return null; - // update the presentation mode - // Doc.UserDoc().presentationMode = 'none'; // set the previus recording view to the play view this.playFFView = this.recordingFFView; @@ -103,9 +95,12 @@ export class RecordingApi { } public clear = (): void => { - // clear the disposeFunc if we are done (not recording) - if (!this.tracking) - this.removeRecordingFFView() + // clear the disposeFunc if we are done (not tracking) + if (!this.tracking) { + this.removeRecordingFFView(); + // update the presentation mode now that we are done tracking + Doc.UserDoc().presentationMode = 'none'; + } // clear presenation data this.currentPresentation = RecordingApi.NULL_PRESENTATION // clear isRecording @@ -114,7 +109,6 @@ export class RecordingApi { this.absoluteStart = -1 } - // call on dispose function to stop tracking movements public removeRecordingFFView = (): void => { this.disposeFunc?.(); @@ -150,7 +144,8 @@ export class RecordingApi { return new Error('[recordingApi.ts] trackMovements(): no presentation') } - console.log('track movment') + // TO FIX: bob + // console.debug('track movment') // get the time const time = new Date().getTime() - this.absoluteStart @@ -262,35 +257,30 @@ export class RecordingApi { }) } - // make a public method that concatenates the movements of the an array of presentations into one array - // TODO: consider the meta data of the presentations + // method that concatenates an array of presentatations into one public concatPresentations = (presentations: Presentation[]): Presentation => { - console.table(presentations); - if (presentations.length === 0) return RecordingApi.NULL_PRESENTATION; - const firstPresentation = presentations[0]; - - let sumTime = firstPresentation.totalTime; - let combinedPresentations = { ...firstPresentation } - presentations.forEach((presentation, i) => { - // already consider the first presentation - if (i === 0) return; - - const { movements, totalTime } = presentation; - if (movements === null) return; - - // add the summed time to the movements - const addedTimeMovements = movements.map(move => { return { ...move, time: move.time + sumTime } }); - // concat the movements already in the combined presentation with these new ones - const newMovements = [...combinedPresentations.movements || [], ...addedTimeMovements]; - - combinedPresentations = { ...combinedPresentations, movements: newMovements } - + // these three will lead to the combined presentation + let combinedMovements: Movement[] = []; + let sumTime = 0; + let combinedMetas: any[] = []; + + presentations.forEach((presentation) => { + const { movements, totalTime, meta } = presentation; + // update movements if they had one + if (movements) { + // add the summed time to the movements + const addedTimeMovements = movements.map(move => { return { ...move, time: move.time + sumTime } }); + // concat the movements already in the combined presentation with these new ones + combinedMovements.push(...addedTimeMovements); + } // update the totalTime sumTime += totalTime; + // concatenate the metas + combinedMetas.push(...meta); }); // return the combined presentation with the updated total summed time - return { ...combinedPresentations, totalTime: sumTime }; + return { movements: combinedMovements, totalTime: sumTime, meta: combinedMetas }; } // Unfinished code for tracing multiple free form views |