Bug 6815: Display an error in if HTTPS not used and webcam unavailable
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
370a10c512
commit
e406dd16b5
1 changed files with 21 additions and 12 deletions
|
@ -43,19 +43,25 @@ function startup() {
|
||||||
camera = document.getElementById("camera");
|
camera = document.getElementById("camera");
|
||||||
uploadfiletext = document.getElementById("uploadfiletext");
|
uploadfiletext = document.getElementById("uploadfiletext");
|
||||||
|
|
||||||
navigator.mediaDevices.getUserMedia({
|
try {
|
||||||
video: true,
|
navigator.mediaDevices.getUserMedia({
|
||||||
audio: false
|
video: true,
|
||||||
})
|
audio: false
|
||||||
.then(function (stream) {
|
|
||||||
video.srcObject = stream;
|
|
||||||
video.play();
|
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.then(function (stream) {
|
||||||
$("#capture-patron-image").hide();
|
video.srcObject = stream;
|
||||||
$("#camera-error").css("display", "flex");
|
video.play();
|
||||||
$("#camera-error-message").text( showMediaErrors( err ) );
|
})
|
||||||
});
|
.catch(function (err) {
|
||||||
|
$("#capture-patron-image").hide();
|
||||||
|
$("#camera-error").css("display", "flex");
|
||||||
|
$("#camera-error-message").text( showMediaErrors( err ) );
|
||||||
|
});
|
||||||
|
} catch(err) {
|
||||||
|
$("#capture-patron-image").hide();
|
||||||
|
$("#camera-error").css("display", "flex");
|
||||||
|
$("#camera-error-message").text( showMediaErrors( err ) );
|
||||||
|
}
|
||||||
|
|
||||||
video.addEventListener('canplay', function () {
|
video.addEventListener('canplay', function () {
|
||||||
if (!streaming) {
|
if (!streaming) {
|
||||||
|
@ -108,6 +114,9 @@ function showMediaErrors( err ){
|
||||||
case "PermissionDeniedError":
|
case "PermissionDeniedError":
|
||||||
output = __("Access to camera denied.");
|
output = __("Access to camera denied.");
|
||||||
break;
|
break;
|
||||||
|
case "TypeError":
|
||||||
|
output = __("This feature is available only in secure contexts (HTTPS).");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
output = __("An unknown error occurred: ") + err;
|
output = __("An unknown error occurred: ") + err;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue