From 7a2f4ea7d58b816e84949c58d66310ac6a18edd6 Mon Sep 17 00:00:00 2001
From: monoguitari <113245090+monoguitari@users.noreply.github.com>
Date: Tue, 22 Aug 2023 15:42:55 -0400
Subject: uptodate

---
 .../views/nodes/RecordingBox/RecordingBox.tsx      | 69 +++++++++++++++++-----
 1 file changed, 55 insertions(+), 14 deletions(-)

(limited to 'src/client/views/nodes/RecordingBox/RecordingBox.tsx')

diff --git a/src/client/views/nodes/RecordingBox/RecordingBox.tsx b/src/client/views/nodes/RecordingBox/RecordingBox.tsx
index 3237ce6cd..5502a1e08 100644
--- a/src/client/views/nodes/RecordingBox/RecordingBox.tsx
+++ b/src/client/views/nodes/RecordingBox/RecordingBox.tsx
@@ -9,7 +9,7 @@ import { VideoBox } from '../VideoBox';
 import { RecordingView } from './RecordingView';
 import { DocumentType } from '../../../documents/DocumentTypes';
 import { Presentation } from '../../../util/TrackMovements';
-import { Doc } from '../../../../fields/Doc';
+import { Doc, DocListCast } from '../../../../fields/Doc';
 import { Id } from '../../../../fields/FieldSymbols';
 import { BoolCast, DocCast } from '../../../../fields/Types';
 import { ScriptingGlobals } from '../../../util/ScriptingGlobals';
@@ -17,6 +17,11 @@ import { DocumentManager } from '../../../util/DocumentManager';
 import { Docs } from '../../../documents/Documents';
 import { CollectionFreeFormView } from '../../collections/collectionFreeForm/CollectionFreeFormView';
 import { CurrentUserUtils } from '../../../util/CurrentUserUtils';
+import { DocumentView } from '../DocumentView';
+import { SettingsManager } from '../../../util/SettingsManager';
+import { PropertiesView } from '../../PropertiesView';
+import { PropertiesSection } from '../../PropertiesSection';
+import { PropertiesDocContextSelector } from '../../PropertiesDocContextSelector';
 
 @observer
 export class RecordingBox extends ViewBoxBaseComponent<FieldViewProps>() {
@@ -91,19 +96,29 @@ ScriptingGlobals.add(function toggleRecording(_readOnly_: boolean) {
         //if recordingbox is true; when we press the stop button. changed vals temporarily to see if changes happening
         console.log('grabbing screen!')
         RecordingBox.screengrabber.Pause?.();
+        const remDoc = RecordingBox.screengrabber.rootDoc;
         setTimeout(() => {
             RecordingBox.screengrabber?.Finish?.();
             RecordingBox.screengrabber!.rootDoc.overlayX = 400; //was 100
             RecordingBox.screengrabber!.rootDoc.overlayY = 100;
-            console.log(RecordingBox.screengrabber?.rootDoc)
+            // DocListCast(Doc.MyOverlayDocs.data)
+            // .filter(doc => doc.slides === RecordingBox.screengrabber!.rootDoc)
+            // .forEach(Doc.RemFromMyOverlay);
+            console.log(RecordingBox.screengrabber)
             RecordingBox.screengrabber = undefined;
         }, 100);
+        //could break if recording takes too long to turn into videobox. If so, either increase time on setTimeout below or find diff place to do this
+        setTimeout(() => {
+            Doc.RemFromMyOverlay(remDoc);
+
+        }, 1000)
         Doc.UserDoc().isRecording = false;
-        // console.log(RecordingBox.screengrabber.dataDoc);
+        
         // Doc.AddDocToList(Doc.UserDoc(), "workspaceRecordings", RecordingBox.screengrabber.dataDoc);
         Doc.AddDocToList(Doc.UserDoc(), "workspaceRecordings", RecordingBox.screengrabber.rootDoc);
-        // console.log(RecordingBox.screengrabber.rootDoc)
-        // console.log(RecordingBox.screengrabber.dataDoc.data?.valueOf);
+       
+        // let recView = Array.from(DocumentManager.Instance.DocumentViews).find(view => view.ComponentView instanceof CollectionFreeFormView);
+        // console.log(recView)
     } else {
         //when we first press mic
         const screengrabber = Docs.Create.WebCamDocument('', {
@@ -125,23 +140,49 @@ ScriptingGlobals.add(function toggleRecording(_readOnly_: boolean) {
     }
 }, 'toggle recording');
 ScriptingGlobals.add(function toggleRecPlayback(value: Doc) {
+    let docval = undefined;
+    Doc.UserDoc().isRecPlayback = true;
+    Doc.UserDoc().currentRecording = value;
     console.log(value)
-    const screenvid = Docs.Create.VideoDocument('', {_width: 384, _height: 216});
-    
-    let ffView = Array.from(DocumentManager.Instance.DocumentViews).find(view => view.ComponentView instanceof CollectionFreeFormView);
-    (ffView?.ComponentView as CollectionFreeFormView).props.addDocument?.(value); 
-
+    value.overlayX = 100;
+    value.overlayY = 100;
+    Doc.AddToMyOverlay(value);
+    DocumentManager.Instance.AddViewRenderedCb(value, docView => {
+        docval = 
+        Doc.UserDoc().currentRecording = docView.ComponentView as VideoBox;
+        // docval.Play();
+    })
+    // let ffView = Array.from(DocumentManager.Instance.DocumentViews).find(view => view.ComponentView instanceof CollectionFreeFormView);
+    // (ffView?.ComponentView as CollectionFreeFormView).props.addDocument?.(value);
 });
+ScriptingGlobals.add(function addRectoWorkspace() {
+    console.log("adding rec to doc");
+    
+})
+ScriptingGlobals.add(function playWorkspaceRec(value: VideoBox) {
+    value.Play();
+})
+ScriptingGlobals.add(function pauseWorkspaceRec(value: VideoBox) {
+    value.Pause();
+})
+ScriptingGlobals.add(function closeWorkspaceRec(value: VideoBox) {
+    value.Pause();
+    Doc.RemFromMyOverlay(value.rootDoc);
+    Doc.UserDoc().currentRecording = undefined;
+    Doc.UserDoc().isRecPlayback = false;
+})
 
-ScriptingGlobals.add(function getCurrRecording() {
-    console.log(RecordingBox.screengrabber);
-});
 ScriptingGlobals.add(function getWorkspaceRecordings() {
     return Doc.UserDoc().workspaceRecordings
 });
 ScriptingGlobals.add(function getIsRecording() {
     return Doc.UserDoc().isRecording;
 })
-
+ScriptingGlobals.add(function getIsRecPlayback() {
+    return Doc.UserDoc().isRecPlayback;
+})
+ScriptingGlobals.add(function getCurrentRecording() {
+    return Doc.UserDoc().currentRecording;  
+})
 
 
-- 
cgit v1.2.3-70-g09d2

