Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

A polyfill to use the Promise-flavoured, `mediaDevices` based version of getUserMedia, in browsers that support *some sort* of getUserMedia.

License

Notifications You must be signed in to change notification settings

mozdevs/mediaDevices-getUserMedia-polyfill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mediaDevices-getUserMedia-polyfill

A polyfill to use the Promise-flavoured, mediaDevices based version of getUserMedia, in browsers that support some sort of getUserMedia.

With this polyfill you can access getUserMedia like this:

navigator.mediaDevices.getUserMedia({ video: true, audio: true }).then(function(stream) {

}, function(error) {

});

versus the old version:

navigator.getUserMedia({ video: true, audio: true }, function(stream) {

}, function(error) {

});

Look at index.html and main.js in the example folder to see how to use the result of the stream to display a video on screen when successful, or how to detect errors and showing a message to the user.

Here is a list of browser support for WebRTC / getUserMedia.

Using the polyfill

Always make sure it's included before anything else that uses getUserMedia in your code.

Option A: include the script

Download and save the polyfill code and include it in your own code:

<head>
	// ... more stuff
	<script src="mediaDevices-getUserMedia-polyfill.js" defer></script>
	<script src="other-code-using-getUserMedia.js" defer></script>
	// ... maybe more stuff
</head>

Option B: use npm

If you prefer to use npm to manage your dependencies:

Install the polyfill:

npm install --save md-gum-polyfill

And load it with require before using code that uses getUserMedia:

require('md-gum-polyfill');

// ... code using getUserMedia...

About

A polyfill to use the Promise-flavoured, `mediaDevices` based version of getUserMedia, in browsers that support *some sort* of getUserMedia.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published