forked from react-native-webrtc/react-native-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 5
/
MediaDevices.js
51 lines (42 loc) · 1.29 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
import {NativeModules} from 'react-native';
import EventTarget from 'event-target-shim';
import getDisplayMedia from './getDisplayMedia';
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 "Screen Capture" compatible {@code getDisplayMedia} implementation.
* See: https://w3c.github.io/mediacapture-screen-share/
*
* @param {*} constraints
* @returns {Promise}
*/
getDisplayMedia(constraints) {
return getDisplayMedia(constraints);
}
/**
* 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();