Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let checking=["audioinput","videoinput"];
- let onlyHas={device:[]};
- navigator.mediaDevices.enumerateDevices()
- .then((devices)=> {
- let haveAllDevices=true;
- devices.forEach((device)=>{
- console.log(device.kind);
- if( device.kind=="audioinput" ){
- onlyHas.audioinput=true;
- }
- if( device.kind=="videoinput" ){
- onlyHas.videoinput=true;
- }
- onlyHas.device.push(device);
- if(!(device.kind==checking[0] || device.kind==checking[1])){
- haveAllDevices=false;
- }
- });
- //do something about ...
- })
- .catch(function(err) {
- console.log(err.name + ": " + err.message);
- });
- if(onlyHas.videoinput===false){
- alert('no cam!');
- }
- if(onlyHas.audioinput===false){
- alert('no microphone!');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement