Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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