Added tests for selecting camera; related to #128
parent
473f4366a5
commit
c4cbf10976
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
export function enumerateDevices() {
|
||||||
|
if (navigator.mediaDevices
|
||||||
|
&& typeof navigator.mediaDevices.enumerateDevices === 'function') {
|
||||||
|
return navigator.mediaDevices.enumerateDevices();
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error('enumerateDevices is not defined'));
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getUserMedia(constraints) {
|
||||||
|
if (navigator.mediaDevices
|
||||||
|
&& typeof navigator.mediaDevices.getUserMedia === 'function') {
|
||||||
|
return navigator.mediaDevices
|
||||||
|
.getUserMedia(constraints);
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error('getUserMedia is not defined'));
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
let devices = [],
|
||||||
|
stream,
|
||||||
|
_constraints,
|
||||||
|
_supported = true;
|
||||||
|
|
||||||
|
export function enumerateDevices() {
|
||||||
|
console.log("enumerateDevices!!!!");
|
||||||
|
return Promise.resolve(devices);
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getUserMedia(constraints) {
|
||||||
|
console.log("getUserMedia!!!!");
|
||||||
|
_constraints = constraints;
|
||||||
|
if (_supported) {
|
||||||
|
return Promise.resolve(stream);
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error("das"));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setDevices(newDevices) {
|
||||||
|
devices = [...newDevices];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setStream(newStream) {
|
||||||
|
stream = newStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getConstraints() {
|
||||||
|
return _constraints;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setSupported(supported) {
|
||||||
|
console.log("Supported: " + supported);
|
||||||
|
_supported = supported;
|
||||||
|
}
|
Loading…
Reference in New Issue