diff --git a/frontend/app/components/Assist/Assist.tsx b/frontend/app/components/Assist/Assist.tsx index 9c8156631..0140fcdd0 100644 --- a/frontend/app/components/Assist/Assist.tsx +++ b/frontend/app/components/Assist/Assist.tsx @@ -1,14 +1,49 @@ -import React from 'react' +import React, { useEffect, useRef } from 'react'; +import { connect } from 'react-redux'; +import { findDOMNode } from 'react-dom'; +import { + PlayerProvider, + attach as attachPlayer, + init as initPlayer, + clean as cleanPlayer, + callPeer, + // scale +} from 'App/player'; import ChatWindow from './ChatWindow/ChatWindow' -import ScreenSharing from './ScreenSharing/ScreenSharing' +//import ScreenSharing from './ScreenSharing/ScreenSharing' -function Assist() { +function Assist({ session, jwt }) { + const screeRef = useRef(null); + useEffect(() => { + initPlayer(session, jwt); + return () => cleanPlayer() + }, [ session.sessionId ]); + useEffect(() => { + if (screeRef.current) { + attachPlayer(findDOMNode(screeRef.current)); + + } + }, [ ]) return ( -
- +
+
+ {/* */}
) } -export default Assist +export default connect(state => ({ + session: { // Testing mock. Should be retrieved from redux + startedAt: 1624314191394, + live: true, + sessionId: "4870254843916045", + }, + jwt: state.get('jwt'), +}))(Assist); diff --git a/frontend/app/components/Assist/ChatWindow/ChatWindow.tsx b/frontend/app/components/Assist/ChatWindow/ChatWindow.tsx index b142cd3a2..e6bcc001a 100644 --- a/frontend/app/components/Assist/ChatWindow/ChatWindow.tsx +++ b/frontend/app/components/Assist/ChatWindow/ChatWindow.tsx @@ -1,14 +1,35 @@ -import React from 'react' -import VideoContainer from '../components/VideoContainer/VideoContainer' +import React, { useState } from 'react'; +import { IconButton } from 'UI'; +import VideoContainer from '../components/VideoContainer'; // import stl from './chatWindow.css'; -function ChatWindow() { + +interface Props { + call: (oStream: MediaStream, cb: (iStream: MediaStream)=>void)=>void +} + +function ChatWindow({ call }: Props) { + const [ inputStream, setInputStream ] = useState(null); + const [ outputStream, setOutputStream ] = useState(null); + + const onCallClick = () => { + navigator.mediaDevices.getUserMedia({video:true, audio:true}) + .then(oStream => { + setOutputStream(oStream); + call(oStream, setInputStream); // Returns false when unable to connect. + // TODO: handle calling state + }) + .catch(console.log) // TODO: handle error in ui + } return (
- +
- + +
+ +
) diff --git a/frontend/app/components/Assist/ChatWindow/index.js b/frontend/app/components/Assist/ChatWindow/index.ts similarity index 100% rename from frontend/app/components/Assist/ChatWindow/index.js rename to frontend/app/components/Assist/ChatWindow/index.ts diff --git a/frontend/app/components/Assist/ScreenSharing/ScreenSharing.tsx b/frontend/app/components/Assist/ScreenSharing/ScreenSharing.tsx index 767b388e7..35d67f91b 100644 --- a/frontend/app/components/Assist/ScreenSharing/ScreenSharing.tsx +++ b/frontend/app/components/Assist/ScreenSharing/ScreenSharing.tsx @@ -2,12 +2,11 @@ import React from 'react' import { Button } from 'UI' function ScreenSharing() { - const videoRef: React.RefObject = React.createRef() + const videoRef = React.createRef() function handleSuccess(stream) { // startButton.disabled = true; - // @ts-ignore - videoRef.current.srcObject = stream; + //videoRef.current?.srcObject = stream; // @ts-ignore window.stream = stream; // make variable available to browser console diff --git a/frontend/app/components/Assist/components/AssistActions/index.js b/frontend/app/components/Assist/components/AssistActions/index.ts similarity index 100% rename from frontend/app/components/Assist/components/AssistActions/index.js rename to frontend/app/components/Assist/components/AssistActions/index.ts diff --git a/frontend/app/components/Assist/components/VideoContainer/VideoContainer.tsx b/frontend/app/components/Assist/components/VideoContainer/VideoContainer.tsx index cab7d5af4..b03702fe4 100644 --- a/frontend/app/components/Assist/components/VideoContainer/VideoContainer.tsx +++ b/frontend/app/components/Assist/components/VideoContainer/VideoContainer.tsx @@ -1,13 +1,22 @@ -import React, { useEffect } from 'react' +import React, { useEffect, useRef } from 'react' import { Button, Icon } from 'UI' -function VideoContainer() { +interface Props { + stream: MediaProvider | null + muted?: boolean +} + +function VideoContainer({ stream, muted = false }: Props) { + const ref = useRef(null); useEffect(() => { - // TODO check for video stream and display - }, []) + if (ref.current) { + ref.current.srcObject = stream; + } + }, [ ref.current, stream ]) return (
+