Skip to content

Commit e4b802d

Browse files
committed
#364: * Camera#stop
1 parent 8034687 commit e4b802d

File tree

5 files changed

+52
-13
lines changed

5 files changed

+52
-13
lines changed

dist/FileAPI.html5.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3285,8 +3285,19 @@
32853285
try {
32863286
this._active = false;
32873287
this.video.pause();
3288-
this.stream.stop();
3289-
} catch( err ){ }
3288+
3289+
try {
3290+
this.stream.stop();
3291+
} catch (err) {
3292+
api.each(this.stream.getTracks(), function (track) {
3293+
track.stop();
3294+
});
3295+
}
3296+
3297+
this.stream = null;
3298+
} catch( err ){
3299+
api.log('[FileAPI.Camera] stop:', err);
3300+
}
32903301
},
32913302

32923303

@@ -3431,7 +3442,9 @@
34313442
ctx.drawImage(video, 0, 0, 1, 1);
34323443
res = ctx.getImageData(0, 0, 1, 1).data[4] != 255;
34333444
}
3434-
catch( e ){}
3445+
catch( err ){
3446+
api.log('[FileAPI.Camera] detectVideoSignal:', err);
3447+
}
34353448
return res;
34363449
}
34373450

dist/FileAPI.html5.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/FileAPI.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3285,8 +3285,19 @@
32853285
try {
32863286
this._active = false;
32873287
this.video.pause();
3288-
this.stream.stop();
3289-
} catch( err ){ }
3288+
3289+
try {
3290+
this.stream.stop();
3291+
} catch (err) {
3292+
api.each(this.stream.getTracks(), function (track) {
3293+
track.stop();
3294+
});
3295+
}
3296+
3297+
this.stream = null;
3298+
} catch( err ){
3299+
api.log('[FileAPI.Camera] stop:', err);
3300+
}
32903301
},
32913302

32923303

@@ -3431,7 +3442,9 @@
34313442
ctx.drawImage(video, 0, 0, 1, 1);
34323443
res = ctx.getImageData(0, 0, 1, 1).data[4] != 255;
34333444
}
3434-
catch( e ){}
3445+
catch( err ){
3446+
api.log('[FileAPI.Camera] detectVideoSignal:', err);
3447+
}
34353448
return res;
34363449
}
34373450

dist/FileAPI.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/FileAPI.Camera.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,19 @@
9191
try {
9292
this._active = false;
9393
this.video.pause();
94-
this.stream.stop();
95-
} catch( err ){ }
94+
95+
try {
96+
this.stream.stop();
97+
} catch (err) {
98+
api.each(this.stream.getTracks(), function (track) {
99+
track.stop();
100+
});
101+
}
102+
103+
this.stream = null;
104+
} catch( err ){
105+
api.log('[FileAPI.Camera] stop:', err);
106+
}
96107
},
97108

98109

@@ -237,7 +248,9 @@
237248
ctx.drawImage(video, 0, 0, 1, 1);
238249
res = ctx.getImageData(0, 0, 1, 1).data[4] != 255;
239250
}
240-
catch( e ){}
251+
catch( err ){
252+
api.log('[FileAPI.Camera] detectVideoSignal:', err);
253+
}
241254
return res;
242255
}
243256

0 commit comments

Comments
 (0)