Advertisement
krot

onMediaError

Jun 18th, 2018
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. connection.onUserStatusChanged = function(event, dontWriteLogs) {
  2.             if (!!connection.enableLogs && !dontWriteLogs) {
  3.                 console.info(event.userid, event.status);
  4.                 // connection.remove(event.userid);
  5.             }
  6.         };
  7. connection.onMediaError = function(error, constraints) {
  8.             if (!!connection.enableLogs) {
  9.                 console.error(error, constraints);
  10.             }
  11.             /* handle the error */
  12.             if (error.name=="NotFoundError" || error.name == "DevicesNotFoundError" ){
  13.                 //required track is missing
  14.                 alert('Нет доступа к камере!');
  15.             } else if (error.name=="NotReadableError" || error.name == "TrackStartError" ){
  16.                  //webcam or mic are already in use
  17.                  alert('Веб-камера или микрофон уже используются!');
  18.             } else if (error.name=="OverconstrainedError" || error.name == "ConstraintNotSatisfiedError" ){
  19.                 //constraints can not be satisfied by avb. devices
  20.                 alert('Камера не существует с этим разрешением!');
  21.             } else if (error.name=="NotAllowedError" || error.name == "PermissionDeniedError" ){
  22.                 //permission denied in browser
  23.                 alert('Разрешение отклонено в браузере!');
  24.             } else if (error.name=="TypeError" || error.name == "TypeError" ){
  25.                 //empty constraints object  
  26.                 alert('Пустой объект ограничений!');    
  27.             } else {
  28.                  //other errors
  29.             }
  30.         };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement