I'm trying to implement the functionality for muting the local video MediaStreamTrack
in my WebRTC application. Here's how I'm approaching this:
function muteVideo() {
if (this._localStream && this._localStream.getVideoTracks().length > 0) {
this._localStream.getVideoTracks()[0].enabled = false;
}
}
In Firefox, the <video>
element to which the local stream is attached correctly renders blackness on mute. In Chrome, blackness is not rendered but the picture freezes. However, in both browsers, the camera's green light stays on, which is clearly undesired behavior. (I want my users to see that the application actually disconnects from the camera on video mute.)
The camera's light goes off if I do this._localStream.stop()
, but then the audio goes off, too.
The current draft of the Media Capture spec mentions the MediaStreamTrack.stop()
method but it currently seems unimplemented in Chrome and Firefox.
So is there a way to mute local video while:
- Making the camera's light go off
- Not losing the audio track?