This chrome extension allows you invoke getUserMedia on any HTTP domain. You can invoke getUserMedia for camera+microphone or screen or tabs.
Source code is available in the ./example/
directory.
if (typeof getUserMediaHttp === 'function') {
alert('Yes. getUserMedia extension is installed & enabled.');
}
if (typeof getUserMediaHttp === 'function') {
navigator.mediaDevices.getUserMedia({
audio: true,
video: true
}).then(function(stream) {
console.log('got stream', stream);
}).catch(function(e) {
console.error(e);
});
}
if (typeof getUserMediaHttp === 'function') {
navigator.mediaDevices.getUserMedia({
audio: false,
video: {
mediaSource: 'screen',
mdiaSourceTypes: ['screen']
}
}).then(function(stream) {
console.log('got stream', stream);
}).catch(function(e) {
console.error(e);
});
}
All getUserMedia constraints are supported. E.g.
if (typeof getUserMediaHttp === 'function') {
navigator.mediaDevices.getUserMedia({
audio: {
echoCancellation: true
},
video: {
width: {
exact: 1920
},
height: {
exact: 1080
},
frameRate: 32
}
}).then(function(stream) {
console.log('got stream', stream);
}).catch(function(e) {
console.error(e);
});
}
For screen capturing:
if (typeof getUserMediaHttp === 'function') {
navigator.mediaDevices.getUserMedia({
audio: false,
video: {
mediaSource: 'screen',
mdiaSourceTypes: ['screen'],
width: screen.width,
height: screen.height,
aspectRatio: 1.77,
frameRate: 64
}
}).then(function(stream) {
console.log('got stream', stream);
}).catch(function(e) {
console.error(e);
});
}
These are custom constraints that are available only in this extension.
mdiaSourceTypes: ['screen', 'window', 'tab', 'audio']
mdiaSourceTypes
allows you choose between what type of screen you want to capture. E.g.
var constraints = {
mdiaSourceTypes: ['screen', 'audio'],
mdiaSourceTypes: ['tab', 'audio'],
mdiaSourceTypes: ['window', 'audio'],
mdiaSourceTypes: ['screen'],
mdiaSourceTypes: ['window'],
mdiaSourceTypes: ['tab'],
}
No more maintaining this extension; as of 2019. So please use at your own risk.
Chrome-Extensions are released under MIT license . Copyright (c) Muaz Khan.