I am using the
simple-peer and
socket.io libraries in a react project, to transmit a video stream and display it to all connected devices in a websocket room, I can receive the stream on the other devices when the stream starts but it does not show in the video
if i print the
stream value in the receptorPeer event (useEffect) it normally returns the stream
I tried to update the video using the
stream directly from the `.then` of getUserMedia and it works normally (but it only displays the video for the user who started the camera, obviously), being that it's the same value, the same stream
What I have tried:
front-end
const initiatorPeer = new SimplePeer({
initiator: true,
stream
})
initiatorPeer.on('signal', (data) => {
socket.emit('stream', data)
})
useEffect(() => {
const receptorPeer = new SimplePeer()
socket.on('stream', (data) => {
receptorPeer.signal(data)
})
receptorPeer.on('stream', stream => {
console.log(stream)
videoRef.current!.srcObject = stream
})
}, [])
back-end
socket.on('stream', data => {
server.io.to('meet').emit('stream', data)
})