Video.js 412 Bytes
Newer Older
Kim, Chaerin's avatar
Kim, Chaerin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import React, { useEffect, useRef, useState } from "react";

const Video = ({ stream, muted }) => {
  const ref = useRef(null);
  const [isMuted, setIsMuted] = useState(false);

  useEffect(() => {
    if (ref.current) ref.current.srcObject = stream;
    if (muted) setIsMuted(muted);
  });

  return (
    <div>
      <video ref={ref} muted={isMuted} autoPlay></video>
    </div>
  );
};

export default Video;