Skip to content

Instantly share code, notes, and snippets.

@ssskip
Created December 1, 2020 13:44
Show Gist options
  • Save ssskip/cdff21985901f3e0f8fe0672e041395c to your computer and use it in GitHub Desktop.
Save ssskip/cdff21985901f3e0f8fe0672e041395c to your computer and use it in GitHub Desktop.
getDisplayMedia (prefers detail over fluent video.)
/**
*
* @param {Object} [constraints={ video: true }] constraints - MediaStreamConstraints
* @returns {Promise<MediaStream>}
*/
export function getDisplayMedia(constraints = defaultDisplayMediaConstraints) {
return global.navigator.mediaDevices
.getDisplayMedia(constraints)
.then(stream => {
// support for Chrome's content hint stuff which prefers detail over fluent video.
// See https://www.w3.org/TR/mst-content-hint/
stream.getVideoTracks().forEach(t => {
if ("contentHint" in t) {
t.contentHint = "detail";
}
});
return stream;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment