mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-12 21:21:42 +08:00
Added test for releasing camera, fixed code-style
This commit is contained in:
Vendored
+13
-1
@@ -6899,7 +6899,8 @@ define('events',[],function() {
|
||||
|
||||
define('camera_access',[],function() {
|
||||
|
||||
|
||||
var streamRef;
|
||||
|
||||
/**
|
||||
* Wraps browser-specific getUserMedia
|
||||
* @param {Object} constraints
|
||||
@@ -6908,6 +6909,7 @@ define('camera_access',[],function() {
|
||||
*/
|
||||
function getUserMedia(constraints, success, failure) {
|
||||
navigator.getUserMedia(constraints, function(stream) {
|
||||
streamRef = stream;
|
||||
var videoSrc = (window.URL && window.URL.createObjectURL(stream)) || stream;
|
||||
success.apply(null, [videoSrc]);
|
||||
}, failure);
|
||||
@@ -6985,6 +6987,13 @@ define('camera_access',[],function() {
|
||||
return {
|
||||
request : function(video, callback) {
|
||||
request(video, callback);
|
||||
},
|
||||
release : function() {
|
||||
var tracks = streamRef && streamRef.getVideoTracks();
|
||||
if (tracks.length) {
|
||||
tracks[0].stop();
|
||||
}
|
||||
streamRef = null;
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -7181,6 +7190,9 @@ function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, Ba
|
||||
},
|
||||
stop : function() {
|
||||
_stopped = true;
|
||||
if (_config.inputStream.type === "LiveStream") {
|
||||
CameraAccess.release();
|
||||
}
|
||||
},
|
||||
onDetected : function(callback) {
|
||||
Events.subscribe("detected", callback);
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user