Add audio functionality to videos

co-authored-by: mitchemmc <mitchemmc@gmail.com>
This commit is contained in:
nicola 2020-03-19 15:07:14 +11:00
parent eb4f3d2a26
commit e92129d8ea
3 changed files with 5 additions and 5 deletions

View File

@ -4,11 +4,11 @@ import { Flex } from "theme-ui";
import PartyVideo from "./PartyVideo";
function Party({ streams }) {
function Party({ streams, localStreamId }) {
return (
<Flex p={4} bg="highlight" sx={{ flexDirection: "column", width: "200px" }}>
{Object.entries(streams).map(([id, stream]) => (
<PartyVideo key={id} stream={stream} />
<PartyVideo key={id} stream={stream} muted={id === localStreamId}/>
))}
</Flex>
);

View File

@ -1,6 +1,6 @@
import React, { useRef, useEffect } from "react";
function PartyVideo({ stream }) {
function PartyVideo({ stream, muted }) {
const videoRef = useRef();
useEffect(() => {
@ -9,7 +9,7 @@ function PartyVideo({ stream }) {
}
}, [stream]);
return <video ref={videoRef} autoPlay muted />;
return <video ref={videoRef} autoPlay muted={muted} />;
}
export default PartyVideo;

View File

@ -83,7 +83,7 @@ function Game() {
/>
</Box>
</Flex>
<Party streams={streams} />
<Party streams={streams} localStreamId={peerId} />
<Flex sx={{ justifyContent: "center" }}>
<Image src={imageSource} />
</Flex>