RTCMultiConnection icon indicating copy to clipboard operation
RTCMultiConnection copied to clipboard

video on/off, audio mute/unmute

Open barakjobs opened this issue 5 years ago • 3 comments

want to mute the audio and off the video for other side user. So other side user not able to see me and listen my voice. whenever I want he can listen my voice and he can see me. suggest me the solution for that

barakjobs avatar May 28 '19 07:05 barakjobs

I only know how mute / unmute, maybe help you

//Mute local voice
connection.streamEvents.selectFirst({local: true}).stream.mute();

//Unmute local voice
connection.streamEvents.selectFirst({local: true}).stream.unmute();

FifineHex avatar Jun 04 '19 20:06 FifineHex

@barakjobs If I understand you question, you want mute/unmute remote tracks?

For remote tracks you can do:

var streamByUserId = connection.streamEvents.selectFirst({ userid: 'remote-userid' }).stream;
streamByUserId.mute();

Also you can send custom event with socket, I think is the best alternative 😄

connection.setCustomSocketEvent('remotemute');
connection.setCustomSocketEvent('remoteunmute');

connection.socket.on('remotemute', function(data) {
    if (data.audio) connection.attachStreams[0].mute('audio');
    if (data.video) connection.attachStreams[0].mute('video');
});
connection.socket.on('remoteunmute', function(data) {
    if (data.audio) connection.attachStreams[0].unmute('audio');
    if (data.video) connection.attachStreams[0].unmute('video');
});

connection.socket.emit('remotemute', { audio: true, video: false });
connection.socket.emit('remoteunmute', { audio: true, video: false });

matiaslopezd avatar Jun 15 '19 07:06 matiaslopezd

@barakjobs If I understand you question, you want mute/unmute remote tracks?

For remote tracks you can do:

var streamByUserId = connection.streamEvents.selectFirst({ userid: 'remote-userid' }).stream;
streamByUserId.mute();

Also you can send custom event with socket, I think is the best alternative 😄

connection.setCustomSocketEvent('remotemute');
connection.setCustomSocketEvent('remoteunmute');

connection.socket.on('remotemute', function(data) {
    if (data.audio) connection.attachStreams[0].mute('audio');
    if (data.video) connection.attachStreams[0].mute('video');
});
connection.socket.on('remoteunmute', function(data) {
    if (data.audio) connection.attachStreams[0].unmute('audio');
    if (data.video) connection.attachStreams[0].unmute('video');
});

connection.socket.emit('remotemute', { audio: true, video: false });
connection.socket.emit('remoteunmute', { audio: true, video: false });

if ı use mute after unmute ı can hear my voice twice.I need to do mute other user not me and unmute other users not me how ı can do it ?

berkaykaradeniz avatar Nov 07 '22 07:11 berkaykaradeniz