https://github.com/phonegap/phonegap-plugin-media-stream
https://github.com/phonegap/phonegap-plugin-media-stream
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/phonegap/phonegap-plugin-media-stream
- Owner: phonegap
- License: apache-2.0
- Created: 2017-05-16T02:27:37.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-11T11:30:29.000Z (over 3 years ago)
- Last Synced: 2025-04-15T17:11:29.189Z (over 1 year ago)
- Language: JavaScript
- Size: 188 KB
- Stars: 33
- Watchers: 15
- Forks: 18
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# phonegap-plugin-media-stream [](https://travis-ci.org/phonegap/phonegap-plugin-media-stream)
------------------------
This plugin provides an implementation of the [W3C Media Capture API](https://w3c.github.io/mediacapture-main/) which allows authorized web applications to access streams from the device's audio and video capturing interfaces, i.e. to use the data available from the camera and the microphone. The streams exposed by the API can be bound directly to the HTML or elements or read and manipulated in the code, including further more specific processing via [Image Capture API](https://w3c.github.io/mediacapture-image/), [Media Recorder API](https://w3c.github.io/mediacapture-record/MediaRecorder.html) or [Real-Time Communication](https://w3c.github.io/webrtc-pc/).
## Installation
phonegap plugin add phonegap-plugin-media-stream
phonegap plugin add https://github.com/phonegap/phonegap-plugin-media-stream.git
## The `mediaDevices` Object
The mediaDevices object has the following methods:
- [getUserMedia(optional MediaStreamConstraints constraints)](https://github.com/phonegap/phonegap-plugin-media-stream#getusermediaoptional-mediastreamconstraints-constraints)
- [getSupportedConstraints()](https://github.com/phonegap/phonegap-plugin-media-stream#getsupportedconstraints)
### getUserMedia(optional MediaStreamConstraints constraints)
The `getUserMedia` method call prompts the user for permission to capture audio or video input. The method returns a promise that when resolved returns a `MediaStream` object. You can constrain what type of media streams are return by passing in an option `MediaStreamConstraints` object.
#### Example
```
navigator.mediaDevices.getUserMedia({
'audio': true,
'video': {
facingMode: 'user'
}
}).then(function(mediaStream) {
// do something with the media stream
});
```
### getSupportedConstraints()
The `getSupportedConstraints` method returns an object which describes which constraints the device supports. You can check the constraints before making a call to `getUserMedia` to make sure that the functionality you want is supported.
#### Example
```
var constraints = navigator.mediaDevices.getSupportedConstraints();
console.log(constraints);
```
## Quirks
The iOS implementation that this plugin provides does not allow you to attach the returned `MediaStream` object to an `audio` or `video` tag. Rather you will use the `MediaStream` object to get a `MediaStreamTrack` to pass to the Image (see [phonegap-plugin-image-capture](https://github.com/phonegap/phonegap-plugin-image-capture)) or Audio capture API.
## [Contributing](.github/CONTRIBUTING.md)
## [LICENSE](LICENSE)