Created
December 1, 2020 13:44
-
-
Save ssskip/cdff21985901f3e0f8fe0672e041395c to your computer and use it in GitHub Desktop.
getDisplayMedia (prefers detail over fluent video.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @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