DEV Community

Andrew
Andrew

Posted on

WebRTC, getDisplayMedia() does not capture sound from the remote stream

Hi,everyone!

I have a web application, which is based on the peersjs library (It is a video conference).

I'm trying to make a recording with 'MediaRecorder', but I'm facing a very unpleasant case.

The code for capturing my desktop stream is the following:

let chooseScreen = document.querySelector('.chooseScreenBtn')
chooseScreen.onclick = async () => {
    let desktopStream = await navigator.mediaDevices.getDisplayMedia({ video:true, audio: true });
}
Enter fullscreen mode Exit fullscreen mode

I then successfully apply my received desktopStream to videoElement in DOM:

const videoElement = doc.querySelector('.videoElement')
  videoElement.srcObject = desktopStream 
  videoElement.muted = false;
  videoElement.onloadedmetadata = ()=>{videoElement.play();}
Enter fullscreen mode Exit fullscreen mode

For example, I get desktopStream on the page with an active conference where everyone hears and sees each other.

To check the video and audio in desktopStream I play some video on the video player on the desktop. I can hear any audio from my desktop but audio from any participant cannot be heard. Of course, when I put the desktopStream in MediaRecorder I get a video file with no sound from anyone except my desktop.It happens when I get desktopStream on the same page with conference, When I take out this functionality to another page, it works fine. Any ideas on how to solve it?

Top comments (2)

Collapse
 
dosvisor profile image
Andrew

I capture audio with getDisplayMedia under lastest version of Chrome browser and I dont understand why i cannot capture both the desktop`s audio and the audio from conference tab. The sound from conference tab is ignored, but the other sound is not. I repeat It again, this happens when I get desktopStream on the same page with conference, when I take this functionality out to another page, it works fine

Collapse
 
falbech profile image
falbech

Have you found any solution for this problem?