RTCMultiConnection
RTCMultiConnection copied to clipboard
video on/off, audio mute/unmute
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
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();
@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 });
@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 ?