Button to mute microphone and cut video

2,629 views
Skip to first unread message

Etienne JACQUOT

unread,
Mar 17, 2015, 5:05:13 AM3/17/15
to kur...@googlegroups.com
Hello everyone

I'm using the demo "group call" to make a proof of concept of videoconference through browsers.
I'm look for a way to add two buttons on the conference room page to mute the user microphone and webcam. I don't know how to make that, espacially what I can change to have this effect. I think that I have to change the constraints on the media stream, but I don't know where ...

Anyone can help me ?

Thanks a lot ! Have a nice day ;)
Etienne

P.S : Sorry for my english. I hope that it is understandable.

Ivan Gracia

unread,
Mar 18, 2015, 4:37:03 AM3/18/15
to Kurento Public

I guess you could do something like this in the client, wherever you have access to your RTCPeerConnection object


var audioTracks = pc.getLocalStreams()[0].getAudioTracks();

// if MediaStream has reference to microphone
if (audioTracks[0]) {
    audioTracks[0].enabled = false;
}
--
You received this message because you are subscribed to the Google Groups "kurento" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurento+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Etienne JACQUOT

unread,
Mar 18, 2015, 5:28:50 AM3/18/15
to kur...@googlegroups.com
Actually, I don't know where and how the access to the user camera and microphone is given ... because nowhere in the javascript or in the java I found a place with something like "getLocalStream" ...
In the javascript, I just have the constraints on the received video streams.

Etienne JACQUOT

unread,
Mar 18, 2015, 6:07:10 AM3/18/15
to kur...@googlegroups.com
Ok, I looked that's it may set up by the kurentoUtils library ... but I still don't how to modify the webrtcpeer by cliking on a button ...
Moving on and I come back to you ;)

Etienne JACQUOT

unread,
Mar 18, 2015, 6:35:04 AM3/18/15
to kur...@googlegroups.com
I tried to do something like that in the confrenceRoom.js file :

function muteMicrophone(name) {
    participants
[name].rtcPeer.userMediaConstraints = {audio : false};
}

But no effect of course ... But I think that's is the good spirit wright ?
Thks for any help :)

Ivan Gracia

unread,
Mar 18, 2015, 6:58:57 AM3/18/15
to Kurento Public
You are on the right track ;-) Your rtcPeer object wraps the RTCPeerConnection object, and osme convenience methods have been included. I don't know which version of the kurento-utils-js you are using, but check if you have available the audioEnabled and videoEnabled properties there. If that's the case, this is how your method would look

function muteMicrophone(name) {
    participants
[name].rtcPeer.audioEnabled = false;
}

If not, try this one.

function muteMicrophone(name) {
    participants
[name].rtcPeer.peerConnection.getLocalStreams()[0].getAudioTracks()[0].enabled = false;
}

Hope that helps,

Ivan Gracia



--
You received this message because you are subscribed to the Google Groups "kurento" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurento+u...@googlegroups.com.

Etienne JACQUOT

unread,
Mar 18, 2015, 9:14:41 AM3/18/15
to kur...@googlegroups.com
Whaou !!! You give me the way ! Thanks so so much, I won several days of work thanks to you !
I give you the solution, in case of somebody need to make the same thing :

function muteMicrophone(name) {
   
   
var audioTracks = participants[name].rtcPeer.pc.getLocalStreams()[0].getAudioTracks();


   
// if MediaStream has reference to microphone
   
if (audioTracks[0]) {
        audioTracks
[0].enabled = false;
   
}
}

I imagine that's it almost the same thing to cut the video, I will search this.
Thansk so much again !
Cheers

Etienne

Etienne JACQUOT

unread,
Mar 18, 2015, 12:26:33 PM3/18/15
to kur...@googlegroups.com
To know for everyone, to cut the video : it is exactly the same way. You just have to change "audio" by "video" and that's it !

Ivan Gracia

unread,
Mar 18, 2015, 12:34:04 PM3/18/15
to Kurento Public
You are most welcome :-) It would work the same way with the videos. In the v6 of the library kurento-utils-js, it will be available in the webrtcPeer wrapper object through the audioEnabled property. 

Cheers,

Ivan Gracia



--

Randall Bennett

unread,
Feb 5, 2016, 7:20:22 PM2/5/16
to kurento
So this was working until recently. I'm not sure when, but it doesn't work anymore in Chrome for sure. We were using it just fine until recently.

I found the previously mentioned audioEnabled and videoEnabled properties, and they don't do anything either. Am I crazy? Is this a chrome change?

rb

Randall Bennett

unread,
Feb 5, 2016, 7:25:56 PM2/5/16
to kurento
On further testing... I think it's a chrome bug. It seems to work fine in firefox. Kurento 6.2 (utils too)

ff43.04 worked, chrome Version 48.0.2564.103 (64-bit) did not. I'll check against beta channel.

Randall Bennett

unread,
Feb 5, 2016, 7:30:30 PM2/5/16
to kurento
Testing against beta channel, nothing even records so.... guessing I need to either update my kurento tools or something. Will get it going.

Ivan Gracia

unread,
Feb 7, 2016, 1:21:21 PM2/7/16
to Kurento Public
Thanks for the feedback!

Ivan Gracia


nadh...@gmail.com

unread,
Jul 12, 2016, 12:52:35 PM7/12/16
to kurento
Hi Ivan,

Unable to mute the audio using both these methods

function muteMicrophone(name) {
    participants
[name].rtcPeer.audioEnabled = false;
}

If not, try this one.

function muteMicrophone(name) {
    participants
[name].rtcPeer.peerConnection.getLocalStreams()[0].getAudioTracks()[0].enabled = false;
}

Can you please provide some details on how to mute the audio using kurento 6.5.

devn...@gmail.com

unread,
Jan 11, 2017, 8:57:22 AM1/11/17
to kurento, nadh...@gmail.com

Hi Everyone ,

I am Unable to mute the Microphone , Basically I am changing the Mic during the conversion or group call , after that i m try to mute the mic but it doesn't . Before change the mic it mute but after change it not,

Kindly suggest me what should i do?

Navneet Sharma

unread,
Dec 21, 2017, 5:39:59 AM12/21/17
to kurento
Hi all,
Thanks for the methods specified here. I am posting here what i did for muting/unmuting of audio/video. 
1. Go to your conferenceroom.js 
2. Make function for muting and unmuting of audio/video.
//For muting of audio
function muteAudio(message)
{
participants[username].rtcPeer.audioEnabled = false;
}
//for unmuting of audio
function unmuteAudio(message)
{
participants[username].rtcPeer.audioEnabled = true;

}
//For muting of video
function muteVideo(message) 
{
    participants[username].rtcPeer.videoEnabled = false;
}
// For unmuting of video
function unmuteVideo(message)
{
participants[username].rtcPeer.videoEnabled = true;
}
 
3. Call these function from client side on button click.

Note- Here username is name of the participant for whom you need to play/pause video and audio.

Cheers !! 
Navneet

ankit...@gmail.com

unread,
Mar 14, 2018, 12:10:42 PM3/14/18
to kurento
Hi Ivan,
I read that changing enabled property will send the empty frames. Is there no reliable way to completely remove and add tracks? Will the addTrack/removeTrack with negotiationneeded event and sending the offer will work for unmuting/muting?

 I am talking about the case in which first people start with mic and wants to turn on camera because I cannot ask for camera before otherwise user may get suspicious when he only wants to use mic and camera later.
Reply all
Reply to author
Forward
0 new messages