I couldnt find your frontend code, but if you want to add mute/unmute of your track:
functionSomeReactComponent(){conststreamRef=useRef()constcaptureUserMedia=useCallback(async()=>{conststream=awaitnavigator.mediaDevices.getUserMedia({audio:true,video:true,})stream.getTracks().forEach(track=>{// add track to your WebRTC connecitonwebRTCConnection.addTrack(track,stream)})streamRef.current=stream},[])consttoggleMute=useCallback(()=>{streamRef.current?.getTracks().forEach(track=>{track.enabled=!track.enabled})},[])// ...render something}
Oh and for screen sharing, just replace getUserMedia with getDisplayMedia:
conststream=awaitnavigator.mediaDevices.getDisplayMedia({audio:true// video is always true for getDisplayMedia})
Programmer/System Admin. Currently working on media solutions.
Love learning new things :)
Posts include a variety of topics, mostly media/computer vision related.
Nice! WebRTC is awesome :)
I couldnt find your frontend code, but if you want to add mute/unmute of your track:
Oh and for screen sharing, just replace
getUserMedia
withgetDisplayMedia
:Thanks for the sample code! :)
There are lots of things you can do with WebRTC, hard to learn but it's fun!
Yea it can take a while to wrap your head around the concept, but very rewarding once you do "get" it.