bigpotato
bigpotato

Reputation: 27517

WebRTC: How to determine if remote user has disabled their video track?

I have a button for disabling the local video track:

button.onclick = function(){
    mediaStream.getVideoTracks()[0].enabled =
     !(mediaStream.getVideoTracks()[0].enabled);
}

I want to be able to detect this on the remote side, so that I can switch out the view with a user friendly image instead of showing a black screen.

Are there any events fired or any properties of the stream that the remote user can check on its local stream object that indicate that the other user shut off their video?

Upvotes: 15

Views: 4560

Answers (1)

Ajay
Ajay

Reputation: 2643

No, there is no direct way to identify the remote video muted state.
You need to pass the video disabled event to remote user with signalling(over ws) or you can use data channel to relay the video disabled/enabled events.

You can predict remote video states based peerConnection stats, but they depends on bandwidth/network fluctuations.
And moreover browser will send some video data (empty/black frames) when we disable(mediaStream.getVideoTracks()[0].enabled = 0) the video track.

Upvotes: 16

Related Questions