Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Video and audio stream control duirng the webrtc call

I can make the webrtc call between 2 parties with video and audio stream together. Is there any way to give user to stop sharing only video or audio during the call?

Assume

A and B are in a webrtc call

during the Call A just stop his video channel so b can only listen the A's voice/audio not video. When A resume video again B can see A face again.

Can anyone help?

like image 338
new developer Avatar asked Mar 21 '23 17:03

new developer


1 Answers

I have already solved it in a efficient way. I have hanlded the local stream audio and video to pasue and resume. See my below way

To pause a local video steam to connected partner: mediastream.getVideoTracks()[0].enabled = false;

To resume a local video steam to connected partner: mediastream.getVideoTracks()[0].enabled = true;

for audio: pasue: mediastream.getAudioTracks()[0].enabled = false;

resume: mediastream.getAudioTracks()[0].enabled = true;

It is working perfectly in my project.

like image 158
new developer Avatar answered Apr 01 '23 21:04

new developer