adrianhajdin/project_video_chat

Only error , not work !

joy-mollick opened this issue · 2 comments

Cloned this library and tried in my local server but everytime I got error navigation.media....... undefined ! Unexpected error .

hi I solved this but idk how it is :D

// This is how I set stream state. object. then stream worked.
const [stream, setStream] = useState({});
    const [name, setName] = useState('');

    const myVideo = useRef();
    const userVideo = useRef();
    const connectionRef = useRef();

    useEffect(() => {
        navigator.mediaDevices.getUserMedia({ video: true, audio: true })
            .then((currentStream) => {
                setStream(currentStream);

                myVideo.current.srcObject = currentStream;
            })

        socket.on('me', (id) => setMe(id))
        socket.on('callperson', ({ from, name: callerName, signal }) => {
            setCall({ isReceivedCall: true, from, name: callerName, signal })
        })
    }, [])