From fb43cc3fc2b931ae284fb6bd6db7551a0188e142 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 19 Mar 2020 12:02:31 +1100 Subject: [PATCH] Added video calling --- src/components/Party.js | 17 ++++++++++ src/components/PartyVideo.js | 15 +++++++++ src/components/Token.js | 1 - src/contexts/GameContext.js | 2 +- src/helpers/useSession.js | 61 ++++++++++++++++++++++++++++++++---- src/routes/Game.js | 12 ++++--- src/routes/Home.js | 2 +- src/routes/Join.js | 2 +- 8 files changed, 97 insertions(+), 15 deletions(-) create mode 100644 src/components/Party.js create mode 100644 src/components/PartyVideo.js diff --git a/src/components/Party.js b/src/components/Party.js new file mode 100644 index 0000000..0ec7e87 --- /dev/null +++ b/src/components/Party.js @@ -0,0 +1,17 @@ +import React from "react"; + +import { Flex } from "theme-ui"; + +import PartyVideo from "./PartyVideo"; + +function Party({ streams }) { + return ( + + {Object.entries(streams).map(([id, stream]) => ( + + ))} + + ); +} + +export default Party; diff --git a/src/components/PartyVideo.js b/src/components/PartyVideo.js new file mode 100644 index 0000000..5c8ca1a --- /dev/null +++ b/src/components/PartyVideo.js @@ -0,0 +1,15 @@ +import React, { useRef, useEffect } from "react"; + +function PartyVideo({ stream }) { + const videoRef = useRef(); + + useEffect(() => { + if (videoRef.current) { + videoRef.current.srcObject = stream; + } + }, [stream]); + + return