Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

getscreenmedia

Package Overview
Dependencies
Maintainers
6
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

getscreenmedia

A browser module for attempting to get access to a MediaStream of a user's screen. With a nice node-like API.

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
707
decreased by-19.2%
Maintainers
6
Weekly downloads
 
Created
Source

getScreenMedia

What is this?

A tiny browser module that gives us a simple API for getting access to a user's screen. It uses https://github.com/otalk/getUserMedia.

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.

If you're not using browserify or you want AMD support use getscreenmedia.bundle.js. Note that if no module system is detected it will attach a function called getScreenMedia to window.

Installing

npm install getscreenmedia

How to use it

First build and install a domain-specific extension for Chrome or/and Firefox.

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.

Keywords

FAQs

Package last updated on 19 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc