user12384512
user12384512

Reputation: 3401

How to close peerConnection in WebRtc

WebRtc sample

If I press call, allow/deny menu is shown in the upper screen. When I press allow, Chrome starts displaying red circle in the header which signals that microphone is active. All other sounds in others Chromes tabs are muted (for example youtube video).

When I press hang, red circle does not dissapears, youtube video in second tab is still muted. I have to press F5 to restore state which was before call.

Is there any PeerConnection to stop the call and stop mic recording ?

Upvotes: 4

Views: 7504

Answers (1)

Benjamin Trent
Benjamin Trent

Reputation: 7566

Yes, the reason the "red light" is still on is that the media tracks in the mediaStream object (called localstream on that particular page) gathered through getusermedia is still playing/active.

To close a media stream and thus release any hold on the local media inputs simply call localstream.stop() that will end the stream and stop accessing the local media input. This will stop all associated media tracks.

You can also do this by calling stop() on the individual media tracks(grabbed from getVideoTracks or getAudioTracks from the mediaStream).

As for other audio being turned down in other pages/apps. Here is the crbug handling that issue.

Side Note: if the media is being pushed through a peerConnection, then you will probably have to renegotiate the connection due to the mediaStream changing.

Upvotes: 6

Related Questions