Skip to content

Commit

Permalink
openvidu-browser: fix getDisplayMedia audio bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloFuente committed Oct 5, 2023
1 parent c8fd209 commit ad96776
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions openvidu-browser/src/OpenVidu/OpenVidu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ export class OpenVidu {
if (navigator.mediaDevices['getDisplayMedia'] && !platform.isElectron()) {
// getDisplayMedia supported
try {
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true });
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true, audio: options.audioSource === 'screen' });
this.addAlreadyProvidedTracks(myConstraints, mediaStream);
if (mustAskForAudioTrackLater) {
return await askForAudioStreamOnly(mediaStream, <MediaStreamConstraints>myConstraints.constraints);
Expand Down Expand Up @@ -1017,7 +1017,7 @@ export class OpenVidu {
) {
const audioSource = publisherProperties.audioSource;
const videoSource = publisherProperties.videoSource;
if (typeof audioSource === 'string') {
if (typeof audioSource === 'string' && audioSource !== 'screen') {
myConstraints.constraints!.audio = { deviceId: { exact: audioSource } };
}

Expand Down
2 changes: 1 addition & 1 deletion openvidu-browser/src/OpenVidu/Publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ export class Publisher extends StreamManager {

try {
if (this.stream.isSendScreen() && navigator.mediaDevices['getDisplayMedia'] && !platform.isElectron()) {
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true, audio: true });
const mediaStream = await navigator.mediaDevices['getDisplayMedia']({ video: true, audio: this.properties.audioSource === 'screen' });
this.openvidu.addAlreadyProvidedTracks(myConstraints, mediaStream);
await getMediaSuccess(mediaStream, definedAudioConstraint);
} else {
Expand Down

0 comments on commit ad96776

Please sign in to comment.