-
Notifications
You must be signed in to change notification settings - Fork 0
/
MediaDevices.js
45 lines (36 loc) · 1.19 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
'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);
}
// Skylink React Native is not supporting screen sharing
getDisplayMedia() {
const error = new Error ("Screensharing is not supported in Skylink React Native SDK");
return new Promise((resolve, reject) => reject(error));
}
}
export default new MediaDevices();