'Audio capture with getDisplayMedia is not worked with Chrome in my Macbook
Audio capture with getDisplayMedia is not worked with Chrome in my Macbook, and it is not asked to check the audio share when the chrome ask user to share the screen, it only recorded the video with the MediaStream. But In my Windows computer, it was fully supported with Chrome browser both with video and audio capture, and it will ask user to check to share the audio or not. May I please ask is that because of the supporting issue or it is the code problem? I am using the lastest version of chrome in macbook Below is my code:
navigator.mediaDevices
.getDisplayMedia({
video: true,
audio: true
})
.then((Mediastream) => {
vm.$set(vm, 'isRecording', true);
if (vm.isInitiator || vm.isConnector) {
if (localStream) {
let localAudio = new MediaStream();
localAudio.addTrack(localStream.getAudioTracks()[0]);
if (Mediastream.getAudioTracks().length != 0) {
let systemAudio = new MediaStream();
systemAudio.addTrack(Mediastream.getAudioTracks()[0]);
let audioContext = new AudioContext();
let audioIn_01 = audioContext.createMediaStreamSource(localAudio);
let audioIn_02 = audioContext.createMediaStreamSource(systemAudio);
let dest = audioContext.createMediaStreamDestination();
audioIn_01.connect(dest);
audioIn_02.connect(dest);
let finalAudioStream = dest.stream;
Mediastream.removeTrack(Mediastream.getAudioTracks()[0]);
Mediastream.addTrack(finalAudioStream.getAudioTracks()[0]);
} else {
Mediastream.addTrack(localStream.getAudioTracks()[0]);
}
}
}
this.createRecorder(Mediastream);
})
.catch((err) => {
this.getUserMediaError(err);
});
Solution 1:[1]
Unfortunately this is a limitation of Chrome on macOS. According to "caniuse.com",
On Windows and Chrome OS the entire system audio can be captured, but on Linux and macOS only the audio of a tab can be captured.
https://caniuse.com/mdn-api_mediadevices_getdisplaymedia_audio_capture_support
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Matt R |