forked from react-native-webrtc/react-native-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MediaDevices.js
39 lines (31 loc) · 968 Bytes
/
MediaDevices.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
import {NativeModules} from 'react-native';
import EventTarget from 'event-target-shim';
import getUserMedia from './getUserMedia';
const {WebRTCModule} = NativeModules;
const MEDIA_DEVICES_EVENTS = [
'devicechange'
];
class MediaDevices extends EventTarget(MEDIA_DEVICES_EVENTS) {
// TODO: implement.
ondevicechange: ?Function;
/**
* W3C "Media Capture and Streams" compatible {@code enumerateDevices}
* implementation.
*/
enumerateDevices() {
return new Promise(resolve => WebRTCModule.enumerateDevices(resolve));
}
/**
* W3C "Media Capture and Streams" compatible {@code getUserMedia}
* implementation.
* See: https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-enumeratedevices
*
* @param {*} constraints
* @returns {Promise}
*/
getUserMedia(constraints) {
return getUserMedia(constraints);
}
}
export default new MediaDevices();