Skip to content

Instantly share code, notes, and snippets.

@rktalusani
Created September 2, 2020 03:55
Show Gist options
  • Save rktalusani/ca854ca8621c20488bea6e62ad04e341 to your computer and use it in GitHub Desktop.
Save rktalusani/ca854ca8621c20488bea6e62ad04e341 to your computer and use it in GitHub Desktop.
var videoConstraints = {};
/* Width and Height optional but, framerate is a must to avoid blinking */
/* videoConstraints.width = 1280;
videoConstraints.height = 720;*/
videoConstraints.frameRate = 25;
var displayMediaStreamConstraints = {
video: videoConstraints,
audio: true
};
try {
const displayMedia = await navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints);
alert(displayMedia.getAudioTracks().length);
screenPublisher = OT.initPublisher('layoutContainer', {
audioSource: displayMedia.getAudioTracks()[0],
videoSource: displayMedia.getVideoTracks()[0],
publishAudio: true,
publishVideo: true,
fitMode: 'contain',
insertMode: 'append',
width: 1920,
height: 1080,
audioFallbackEnabled: false,
}, (error) => {
if (error) {
handleError(error);
return;
}
OTSession.publish(screenPublisher, (err) => {
if (err) {
handleError(error);
return;
}
})
});
} catch (error) {
handleError(error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment