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");
|
||||
uploadfiletext = document.getElementById("uploadfiletext");
|
||||
|
||||
navigator.mediaDevices.getUserMedia({
|
||||
video: true,
|
||||
audio: false
|
||||
})
|
||||
.then(function (stream) {
|
||||
video.srcObject = stream;
|
||||
video.play();
|
||||
try {
|
||||
navigator.mediaDevices.getUserMedia({
|
||||
video: true,
|
||||
audio: false
|
||||
})
|
||||
.catch(function (err) {
|
||||
$("#capture-patron-image").hide();
|
||||
$("#camera-error").css("display", "flex");
|
||||
$("#camera-error-message").text( showMediaErrors( err ) );
|
||||
});
|
||||
.then(function (stream) {
|
||||
video.srcObject = stream;
|
||||
video.play();
|
||||
})
|
||||
.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 () {
|
||||
if (!streaming) {
|
||||
|
@ -108,6 +114,9 @@ function showMediaErrors( err ){
|
|||
case "PermissionDeniedError":
|
||||
output = __("Access to camera denied.");
|
||||
break;
|
||||
case "TypeError":
|
||||
output = __("This feature is available only in secure contexts (HTTPS).");
|
||||
break;
|
||||
default:
|
||||
output = __("An unknown error occurred: ") + err;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue