aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/webcam/DashWebRTCVideo.tsx
diff options
context:
space:
mode:
authorMohammad Amoush <47069173+mamoush34@users.noreply.github.com>2020-02-08 13:23:00 -0500
committerMohammad Amoush <47069173+mamoush34@users.noreply.github.com>2020-02-08 13:23:00 -0500
commit38d0d467ee4c27709d482bfea7505e3f3729a455 (patch)
treeb885f6f270fd8a913e03d5ad7167d34d19b513c8 /src/client/views/webcam/DashWebRTCVideo.tsx
parentd3db291c2587bf1284f9d0a8ee7d06fd8ec7a252 (diff)
Ui Update and stream track stoppage added
Diffstat (limited to 'src/client/views/webcam/DashWebRTCVideo.tsx')
-rw-r--r--src/client/views/webcam/DashWebRTCVideo.tsx50
1 files changed, 27 insertions, 23 deletions
diff --git a/src/client/views/webcam/DashWebRTCVideo.tsx b/src/client/views/webcam/DashWebRTCVideo.tsx
index 191f5750d..f93d4a662 100644
--- a/src/client/views/webcam/DashWebRTCVideo.tsx
+++ b/src/client/views/webcam/DashWebRTCVideo.tsx
@@ -12,7 +12,7 @@ import { DocServer } from "../../DocServer";
import { DocumentView } from "../nodes/DocumentView";
import { Utils } from "../../../Utils";
import { MessageStore } from "../../../server/Message";
-import { initialize } from "./WebCamLogic";
+import { initialize, hangup } from "./WebCamLogic";
const mediaStreamConstraints = {
video: true,
@@ -29,12 +29,12 @@ const offerOptions = {
export class DashWebRTCVideo extends React.Component<CollectionFreeFormDocumentViewProps & FieldViewProps> {
@observable private localVideoEl: HTMLVideoElement | undefined;
@observable private peerVideoEl: HTMLVideoElement | undefined;
- // private roomText: HTMLInputElement | undefined;
+ private roomText: HTMLInputElement | undefined;
// private roomOfCam: string = "";
// private isChannelReady = false;
// private isInitiator = false;
// private isStarted = false;
- // @observable remoteVideoAdded: boolean = false;
+ @observable remoteVideoAdded: boolean = false;
// localStream: MediaStream | undefined;
// private pc: any;
// remoteStream: MediaStream | undefined;
@@ -56,17 +56,22 @@ export class DashWebRTCVideo extends React.Component<CollectionFreeFormDocumentV
// };
componentDidMount() {
- // DocumentDecorations.Instance.addCloseCall(this.closeConnection);
- setTimeout(() => initialize(), 10000);
+ DocumentDecorations.Instance.addCloseCall(this.closeConnection);
+ // setTimeout(() => initialize(), 10000);
// let self = this;
// window.onbeforeunload = function () {
// self.sendMessage('bye');
// };
}
- // closeConnection: CloseCall = () => {
- // this.hangup();
- // }
+ closeConnection: CloseCall = () => {
+ hangup();
+ }
+
+ @action
+ changeUILook = () => {
+ this.remoteVideoAdded = true;
+ }
// componentWillUnmount() {
// }
@@ -335,18 +340,17 @@ export class DashWebRTCVideo extends React.Component<CollectionFreeFormDocumentV
- // /**
- // * Function that submits the title entered by user on enter press.
- // */
- // private onEnterKeyDown = (e: React.KeyboardEvent) => {
- // if (e.keyCode === 13) {
- // let submittedTitle = this.roomText!.value;
- // this.roomText!.value = "";
- // this.roomText!.blur();
- // this.roomOfCam = submittedTitle;
- // this.init(submittedTitle);
- // }
- // }
+ /**
+ * Function that submits the title entered by user on enter press.
+ */
+ private onEnterKeyDown = (e: React.KeyboardEvent) => {
+ if (e.keyCode === 13) {
+ let submittedTitle = this.roomText!.value;
+ this.roomText!.value = "";
+ this.roomText!.blur();
+ initialize(submittedTitle, this.changeUILook);
+ }
+ }
public static LayoutString(fieldKey: string) { return FieldView.LayoutString(DashWebRTCVideo, fieldKey); }
@@ -373,11 +377,11 @@ export class DashWebRTCVideo extends React.Component<CollectionFreeFormDocumentV
let content =
<div className="webcam-cont" style={{ width: "100%", height: "100%" }} onWheel={this.onPostWheel} onPointerDown={this.onPostPointer} onPointerMove={this.onPostPointer} onPointerUp={this.onPostPointer}>
<div className="webcam-header">DashWebRTC</div>
- {/* <input id="roomName" type="text" placeholder="Enter room name" ref={(e) => this.roomText = e!} onKeyDown={this.onEnterKeyDown} /> */}
- <video id="localVideo" autoPlay playsInline ref={(e) => {
+ <input id="roomName" type="text" placeholder="Enter room name" ref={(e) => this.roomText = e!} onKeyDown={this.onEnterKeyDown} />
+ <video id="localVideo" className={"RTCVideo" + (this.remoteVideoAdded ? " side" : " main")} autoPlay playsInline ref={(e) => {
this.localVideoEl = e!;
}}></video>
- <video id="remoteVideo" autoPlay playsInline ref={(e) => {
+ <video id="remoteVideo" className="RTCVideo main" autoPlay playsInline ref={(e) => {
this.peerVideoEl = e!;
}}></video>