From dd818efee16f554662500aaaee3d11adeb4bf64d Mon Sep 17 00:00:00 2001
From: monoguitari <113245090+monoguitari@users.noreply.github.com>
Date: Thu, 24 Aug 2023 00:21:42 -0400
Subject: Current Implementation topbar video

---
 .../views/nodes/RecordingBox/RecordingBox.tsx      | 53 ++++++++++++++++++----
 1 file changed, 44 insertions(+), 9 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 fdb00c552..ade8d0d45 100644
--- a/src/client/views/nodes/RecordingBox/RecordingBox.tsx
+++ b/src/client/views/nodes/RecordingBox/RecordingBox.tsx
@@ -24,6 +24,8 @@ import { PropertiesSection } from '../../PropertiesSection';
 import { PropertiesDocContextSelector } from '../../PropertiesDocContextSelector';
 import { listSpec } from '../../../../fields/Schema';
 import { DragManager } from '../../../util/DragManager';
+import { SelectionManager } from '../../../util/SelectionManager';
+import { AudioBox } from '../AudioBox';
 
 @observer
 export class RecordingBox extends ViewBoxBaseComponent<FieldViewProps>() {
@@ -143,44 +145,71 @@ 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)
     value.overlayX = 100;
     value.overlayY = 100;
     if (!Doc.UserDoc().isAddRecToDocMode) {
-    Doc.AddToMyOverlay(value);
+        Doc.UserDoc().isRecPlayback = true;
+        Doc.UserDoc().isWorkspaceRecPlaying = true;
+        Doc.AddToMyOverlay(value);
         DocumentManager.Instance.AddViewRenderedCb(value, docView => {
-            docval = 
-            Doc.UserDoc().currentRecording = docView.ComponentView as VideoBox;
+            // docval = 
+            Doc.UserDoc().currentRecording = docView.ComponentView as RecordingBox;
+            SelectionManager.SelectSchemaViewDoc(value);
+            
             // docval.Play();
+
     })} else {
-        let recordingIndex = Array.from(Doc.UserDoc().workspaceRecordings).indexOf(Doc);
+        let recordingIndex = Array.from(Doc.UserDoc().workspaceRecordings).indexOf(value);
         DragManager.StartDropdownDrag([document.createElement('div')],new DragManager.DocumentDragData([value]), 1, 1, recordingIndex);
-    
     }
     
     // let ffView = Array.from(DocumentManager.Instance.DocumentViews).find(view => view.ComponentView instanceof CollectionFreeFormView);
     // (ffView?.ComponentView as CollectionFreeFormView).props.addDocument?.(value);
 });
-ScriptingGlobals.add(function addRectoWorkspace(value: VideoBox) {
+ScriptingGlobals.add(function addRectoWorkspace(value: RecordingBox) {
     console.log("adding rec to doc");
-    console.log(value.rootDoc);
-    Doc.UserDoc().isAddRecToDocMode = true;
+    console.log(value);
+     let ffView = Array.from(DocumentManager.Instance.DocumentViews).find(view => view.ComponentView instanceof CollectionFreeFormView);
+    (ffView?.ComponentView as CollectionFreeFormView).props.addDocument?.(value.rootDoc);
+    let recordingIndex = Array.from(Doc.UserDoc().workspaceRecordings).indexOf(value.rootDoc);
+    console.log(recordingIndex);
+    Cast(Doc.UserDoc().workspaceRecordings, listSpec(Doc), null)?.splice(recordingIndex, 1);
+    Doc.UserDoc().isAddRecToDocMode = false;
+    Doc.RemFromMyOverlay(value.rootDoc);
+    Doc.UserDoc().currentRecording = undefined;
+    Doc.UserDoc().isRecPlayback = false;
+    Doc.UserDoc().isAddRecToDocMode = false;
+    // Doc.UserDoc().isAddRecToDocMode = true;
+    Doc.UserDoc().isWorkspaceRecPlaying = false;
+    Doc.UserDoc().isWorkspaceRecPaused = false;
+    // let audiodoc: Doc = Docs.Create.AudioDocument(value.dataDoc.data, {
+    //     x: 100, 
+    //     y: 100
+    // });
     
+    // (ffView?.ComponentView as CollectionFreeFormView).props.addDocument?.(audiodoc);
+
     
 })
 ScriptingGlobals.add(function playWorkspaceRec(value: VideoBox) {
     value.Play();
+    Doc.UserDoc().isWorkspaceRecPlaying = false;
+    Doc.UserDoc().isWorkspaceRecPaused = true;
 })
 ScriptingGlobals.add(function pauseWorkspaceRec(value: VideoBox) {
     value.Pause();
+    Doc.UserDoc().isWorkspaceRecPlaying = true;
+    Doc.UserDoc().isWorkspaceRecPaused = false;
 })
 ScriptingGlobals.add(function closeWorkspaceRec(value: VideoBox) {
     value.Pause();
     Doc.RemFromMyOverlay(value.rootDoc);
     Doc.UserDoc().currentRecording = undefined;
     Doc.UserDoc().isRecPlayback = false;
+    Doc.UserDoc().isWorkspaceRecPlaying = false;
+    Doc.UserDoc().isWorkspaceRecPaused = false;
 })
 
 ScriptingGlobals.add(function getWorkspaceRecordings() {
@@ -195,5 +224,11 @@ ScriptingGlobals.add(function getIsRecPlayback() {
 ScriptingGlobals.add(function getCurrentRecording() {
     return Doc.UserDoc().currentRecording;  
 })
+ScriptingGlobals.add(function getIsWorkspaceRecPlaying() {
+    return Doc.UserDoc().isWorkspaceRecPlaying;
+})
+ScriptingGlobals.add(function getIsWorkspaceRecPaused() {
+    return Doc.UserDoc().isWorkspaceRecPaused;
+})
 
 
-- 
cgit v1.2.3-70-g09d2

