From ab43ba2fb3cd907f4e8eb9d612f86ccd8b11d773 Mon Sep 17 00:00:00 2001 From: kimdahey Date: Sun, 15 Sep 2019 15:50:08 -0400 Subject: audio added --- src/client/views/webcam/DashWebCam.tsx | 69 ++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/client/views/webcam/DashWebCam.tsx b/src/client/views/webcam/DashWebCam.tsx index cd908b251..4c78e5105 100644 --- a/src/client/views/webcam/DashWebCam.tsx +++ b/src/client/views/webcam/DashWebCam.tsx @@ -1,11 +1,12 @@ import React = require("react"); import { observer } from "mobx-react"; import { FieldViewProps, FieldView } from "../nodes/FieldView"; -import { observable } from "mobx"; +import { observable, action } from "mobx"; import { DocumentDecorations } from "../DocumentDecorations"; import { InkingControl } from "../InkingControl"; import { CollectionFreeFormDocumentViewProps } from "../nodes/CollectionFreeFormDocumentView"; +//https://github.com/mozmorris/react-webcam is the source code used for the bigger part of this implementation. It's only modified to fit our current system. function hasGetUserMedia() { @@ -26,10 +27,15 @@ interface WebcamProps { videoConstraints?: MediaStreamConstraints["video"]; } +interface WebcamState { + hasUserMedia: boolean; + src?: string; +} + @observer export class DashWebCam extends React.Component & { layoutKey: string, -}> { +}, WebcamState> { static defaultProps = { audio: true, imageSmoothing: true, @@ -46,24 +52,24 @@ export class DashWebCam extends React.Component track.stop()); this.stream!.getAudioTracks().map(track => track.stop()); @@ -94,16 +100,16 @@ export class DashWebCam extends React.Component this.hasUserMedia = false); props.onUserMediaError(err!); return; @@ -251,16 +258,26 @@ export class DashWebCam extends React.Component this.hasUserMedia = true); + } catch (error) { this.setState({ hasUserMedia: true, src: window.URL.createObjectURL(stream) }); + console.log("State src set: ", this.state.src); + + // action(() => this.hasUserMedia = true); + // action(() => this.src = window.URL.createObjectURL(stream)); } props.onUserMedia(); @@ -291,7 +308,7 @@ export class DashWebCam extends React.Component