Switch branches/tags
Nothing to show
Find file History
Latest commit 0ddd96d Oct 21, 2018

README.md

Call getUserMedia on any HTTP website

This chrome extension allows you invoke getUserMedia on any HTTP domain. You can invoke getUserMedia for camera+microphone or screen or tabs.

If disabled by chrome? Then please install using chrome://extensions

Try it now in CWS

Install getUserMedia Extension

Try Following Demo After Installation

Source code is available in the ./example/ directory.

First Step, Check If Extension Installed

if (typeof getUserMediaHttp === 'function') {
    alert('Yes. getUserMedia extension is installed & enabled.');
}

Capture Camera+Microphone

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);
    });
}

Capture Screen

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);
    });
}

Supported Constraints

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);
    });
}

Special Constraints

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'],
}

License

Chrome-Extensions are released under MIT licence . Copyright (c) Muaz Khan.