# get-user-media-promise

> Light-weight wrapper for the newer Promise-based MediaDevices.getUserMedia API with a fallback to navigator.getUserMedia (and it's prefixed variants)

Latest version **1.1.4** (published 2018-04-30) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install get-user-media-promise
pnpm add get-user-media-promise
yarn add get-user-media-promise
bun add get-user-media-promise
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2018-04-30 |
| First published | 2016-03-08 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | Nathan Friedly - http://nfriedly.com |
| Maintainers | nfriedly |
| Keywords | getUserMedia, webkitGetUserMedia, mozGetUserMedia, navigator.msGetUserMedia, get, user, media, promise, MediaDevices, ponyfill, polyfill, pollyfill, shim, wrapper, helper, light, small, tiny |

## Links

- npm: https://www.npmjs.com/package/get-user-media-promise
- Repository: https://github.com/nfriedly/get-user-media-promise
- Homepage: https://github.com/nfriedly/get-user-media-promise#readme
- Issues: https://github.com/nfriedly/get-user-media-promise/issues
- npm.io page: https://npm.io/package/get-user-media-promise

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 1.1.4 (latest) — 2018-04-30
- 1.1.3 — 2018-04-17
- 1.1.1 — 2017-01-12
- 1.1.0 — 2017-01-12
- 1.0.0 — 2016-03-08

## README

# get-user-media-promise

[![Build Status](https://travis-ci.org/nfriedly/get-user-media-promise.svg?branch=master)](https://travis-ci.org/nfriedly/get-user-media-promise)
[![npm-version](https://img.shields.io/npm/v/get-user-media-promise.svg)](https://www.npmjs.com/package/get-user-media-promise)
![bower-version](http://badge.fury.io/bo/get-user-media-promise.svg)

Light-weight Ponyfill/Polyfill for [navigator.mediaDevices.getUserMedia] (the newer newer [Promise]-based API). Wraps the older callback-based [navigator.getUserMedia] when necessary.

Behaves as a ponyfill (doesn't touch globals) when used via browserify/webpack/etc. or as a polyfill (sets globals) when included as a standalone library.

Less than 0.5kb after minification and gzipping (about 5% of the size of the [other] getUserMedia shim).

**Note**: this will only work in web browsers, and only [fairly current ones](http://caniuse.com/#feat=stream) at that. 

Additionally, this library does not attempt to reformat constraints for cross-browser support, so if you need advanced audio/video constraints, the [other library][other] may be a better choice.

## Installation:

### npm

    npm install --save get-user-media-promise
    
### Bower

    bower install --save get-user-media-promise
    
### Standalone
 
 Download the [latest release][releases] from GitHub.

## Usage: 

 * With a bundler such as Require.js, Browserify, or WebPack: require() the module and it returns a `getUserMedia()` method that will always return a Promise or Promise-like object.
 * As a standalone library: when neither `define()` nor `module` are defined, the module will go into polyfill mode, setting `navigator.mediaDevices.getUserMedia()` if that method is not already defined or doing nothing if it is.
 
 Then:
 
```js
var getUserMedia = require('get-user-media-promise'); // or navigator.mediaDevices.getUserMedia when used standalone

getUserMedia({audio: true, video: true})
  .then(function(mediaStream) {
    console.log(mediaStream);
  })
  .catch(function(error) {
    console.log('error');
  });
```

Check browser support ahead of time via the `isSupported` property:

```js
console.log(getUserMedia.isSupported);
```

[navigator.mediaDevices.getUserMedia]: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
[Promise]: https://developer.mozilla.org/en-US/docs/Web/API/Promise
[navigator.getUserMedia]: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia
[other]: https://www.npmjs.com/package/getusermedia
[releases]: https://github.com/nfriedly/get-user-media-promise/releases

---
_Source: https://npm.io/package/get-user-media-promise · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
