Bugzilla – Attachment 106783 Details for
Bug 6815
Capture member photo via webcam
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6815: Attempt to get web cam working on sandbox
Bug-6815-Attempt-to-get-web-cam-working-on-sandbox.patch (text/plain), 4.28 KB, created by
Mark Tompsett
on 2020-07-11 13:30:31 UTC
(
hide
)
Description:
Bug 6815: Attempt to get web cam working on sandbox
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2020-07-11 13:30:31 UTC
Size:
4.28 KB
patch
obsolete
>From bb0a41e3dc79698999102e63de387e09636693c2 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Sat, 11 Jul 2020 13:29:37 +0000 >Subject: [PATCH] Bug 6815: Attempt to get web cam working on sandbox > >--- > .../intranet-tmpl/prog/js/pages/patron-webcam.js | 77 ++++++++++++++-------- > 1 file changed, 49 insertions(+), 28 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/patron-webcam.js b/koha-tmpl/intranet-tmpl/prog/js/pages/patron-webcam.js >index bead6bb0da..4ee752edb5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/pages/patron-webcam.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/pages/patron-webcam.js >@@ -1,20 +1,19 @@ >+var div_take_image = document.getElementById('take_patron_image'); >+var mediaConfig = { video: true }; >+var errBack = function( error ) { >+ div_take_image.style.display = 'none'; >+ if( error.name = "NotAllowedError" ){ >+ alert("No permission to use camera"); >+ } else { >+ alert("Cannot load camera interface"); >+ } >+}; >+ > function initializeCamera( camera_form ){ > // Grab elements, create settings, etc. > console.log(camera_form); > var context = camera_form.find("#canvas")[0].getContext('2d'); > var video = camera_form.find("#video")[0]; >- var mediaConfig = { video: true }; >- var errBack = function( error ) { >- if( error.name = "NotAllowedError" ){ >- alert("No permission to use camera"); >- } else { >- alert("Cannot load camera interface"); >- } >- }; >- navigator.getMedia = ( navigator.getUserMedia || // use the proper vendor prefix >- navigator.webkitGetUserMedia || >- navigator.mozGetUserMedia || >- navigator.msGetUserMedia ); > > // Put video listeners into place > if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { >@@ -28,6 +27,11 @@ function initializeCamera( camera_form ){ > } > /* Legacy code below! */ > else { >+ navigator.getMedia = ( navigator.getUserMedia || // use the proper vendor prefix >+ navigator.webkitGetUserMedia || >+ navigator.mozGetUserMedia || >+ navigator.msGetUserMedia ); >+ > navigator.getMedia( > mediaConfig, > function(stream) { >@@ -72,23 +76,40 @@ function initializeCamera( camera_form ){ > }); > } > >-navigator.getMedia = ( navigator.getUserMedia || // use the proper vendor prefix >- navigator.webkitGetUserMedia || >- navigator.mozGetUserMedia || >- navigator.msGetUserMedia ); >+// Detect webcam, and make 'Take' button available. >+if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { >+ navigator.mediaDevices.getUserMedia(mediaConfig).then( >+ function(stream) { >+ div_take_image.style.display = 'block'; >+ stream.getTracks().forEach(function(track) { >+ if (track.readyState == 'live' && track.kind === 'video') { >+ track.stop(); >+ } >+ }); >+ }, >+ errBack >+ ); >+} else { >+ navigator.getMedia = ( navigator.getUserMedia || // use the proper vendor prefix >+ navigator.webkitGetUserMedia || >+ navigator.mozGetUserMedia || >+ navigator.msGetUserMedia ); > >-var div_take_image = document.getElementById('take_patron_image'); >-navigator.getMedia({video: true}, function(stream) { >- div_take_image.style.display = 'block'; >- stream.getTracks().forEach(function(track) { >- if (track.readyState == 'live' && track.kind === 'video') { >- track.stop(); >- } >- }); >- }, function() { >- div_take_image.style.display = 'none'; >- } >-); >+ navigator.getMedia( >+ mediaConfig, >+ function(stream) { >+ div_take_image.style.display = 'block'; >+ stream.getTracks().forEach(function(track) { >+ if (track.readyState == 'live' && track.kind === 'video') { >+ track.stop(); >+ } >+ }); >+ }, >+ function() { >+ div_take_image.style.display = 'none'; >+ } >+ ); >+} > > > $(document).ready(function(){ >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6815
:
22623
|
29613
|
38518
|
91302
|
91303
|
91335
|
99015
|
99016
|
99757
|
106774
|
106775
|
106776
|
106777
|
106782
|
106783
|
106787
|
106788
|
106789
|
106790
|
106791
|
106792
|
106793
|
106794
|
106795
|
106796
|
106797
|
106798
|
106799
|
106800
|
106801
|
106802
|
106803
|
106804
|
106938
|
106939
|
106940
|
131174
|
131554
|
131985
|
131987
|
131988
|
131999
|
132000
|
132001