aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/RecordingBox/RecordingBox.tsx
blob: 86358e838673872d0e7deb041151015fbc3cc93d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { action, observable } from "mobx";
import { observer } from "mobx-react";
import * as React from "react";
import { AudioField, VideoField } from "../../../../fields/URLField";
import { Upload } from "../../../../server/SharedMediaTypes";
import { ViewBoxBaseComponent } from "../../DocComponent";
import { FieldView } from "../FieldView";
import { VideoBox } from "../VideoBox";
import { RecordingView } from './RecordingView';
import { DocumentType } from "../../../documents/DocumentTypes";


@observer
export class RecordingBox extends ViewBoxBaseComponent() {

      public static LayoutString(fieldKey: string) { return FieldView.LayoutString(RecordingBox, fieldKey); }

      private _ref: React.RefObject<HTMLDivElement> = React.createRef();

      constructor(props: any) {
            super(props);
      }

      @observable result: Upload.FileInformation | undefined = undefined
      @observable videoDuration: number | undefined = undefined

      @action
      setVideoDuration = (duration: number) => {
            this.videoDuration = duration
      }

      @action
      setResult = (info: Upload.FileInformation) => {
            console.log("Setting result to " + info)
            this.result = info
            console.log(this.result.accessPaths.agnostic.client)
            this.dataDoc.type = DocumentType.VID;
            console.log(this.videoDuration)
            this.dataDoc[this.fieldKey + "-duration"] = this.videoDuration;

            this.layoutDoc.layout = VideoBox.LayoutString(this.fieldKey);
            // this.dataDoc.nativeWidth = this.dataDoc.nativeHeight = undefined;
            // this.layoutDoc._fitWidth = undefined;
            this.dataDoc[this.props.fieldKey] = new VideoField(this.result.accessPaths.agnostic.client);
      }

      render() {
            return <div className="recordingBox" ref={this._ref}>
                  {!this.result && <RecordingView setResult={this.setResult} setDuration={this.setVideoDuration} />}
                  {/* {!this.result ? <RecordingView setResult={this.setResult} /> :
                        <p>video box</p>} */}
            </div>;
      }
}