Giter VIP home page Giter VIP logo

getscreenmedia's Introduction

getScreenMedia

What is this?

A tiny browser module that gives us a simple API for getting access to a user's screen.

It gives us a cleaner node.js-style, error-first API and cross-browser handling. No browser support checking necessary; lack of support is treated in the same way as when the user rejects the request: the callback gets passed an error as the first argument.

Suitable for use with browserify/CommonJS on the client.

Installing

npm install getscreenmedia

How to use it

First build and install a domain-specific extension for Chrome. Firefox and Microsoft Edge will work out of the box.

Use the snippet below to get a screen stream, similar to getUserMedia.

var getScreenMedia = require('getscreenmedia');

getScreenMedia(function (err, stream) {
    // if the browser doesn't support user media
    // or the user says "no" the error gets passed
    // as the first argument.
    if (err) {
       console.log('failed');
    } else {
       console.log('got a stream', stream);  
    }
});

Why?

All supported browsers require the use of an extension and don't offer an cross-browser API which is annoying and error-prone. Node-style (error-first) APIs that are cross-browser, installable with npm and runnable on the client === win!

Error handling

Error handling (denied requests, etc) are handled mostly by the underlying getUserMedia lib. However this adds one more error type:

  • "HTTPS_REQUIRED"

Because that's a current requirement of Chrome.

See the handling errors section of the getUserMedia lib for details about how errors are handled.

License

MIT The Firefox sample extension is licensed under MPL 2.0

Created By

If you like this, follow: @HenrikJoreteg on twitter.

getscreenmedia's People

Contributors

dandv avatar devvmh avatar fippo avatar henrikjoreteg avatar legastero avatar michaeljcole avatar rstormsf avatar sualko avatar tgabi333 avatar wballard avatar xdumaine avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.