MCPcopy Create free account
hub / github.com/BloombergGraphics/whatiscode / gotStream

Function gotStream

modules/certificate/certificate.js:34–75  ·  view source on GitHub ↗
(stream)

Source from the content-addressed store, hash-verified

32 setTimeout(init, 0)
33
34 function gotStream(stream) {
35 if (window.URL) {
36 video.src = window.URL.createObjectURL(stream);
37 } else {
38 video.src = stream; // Opera.
39 }
40
41 vidStream = stream
42
43 video.onerror = function(e) {
44 stream.getTracks()[0].stop();
45 };
46
47 video.width = certificate.width;
48 video.height = certificate.height;
49
50 output.width = certificate.width;
51 output.height = certificate.height;
52
53 video.onloadedmetadata = function(e) {
54
55 portrait = video.videoWidth < video.videoHeight
56 console.log('portrait', portrait)
57
58 video.style.height = height + 'px'
59 video.style.width = 'auto'
60
61 canvas.width = certificate.width
62 canvas.height = certificate.height
63
64 video.style.left = offsetX + 'px'
65 video.style.top = offsetY + 'px'
66
67 minD = Math.min(video.videoWidth, video.videoHeight)
68
69 x = (video.videoWidth - minD) / 2
70 y = (video.videoHeight - minD) / 2
71
72 //automatically take picture
73 window.setTimeout(capture, 400)
74 };
75 }
76
77 function noStream(e) {
78 // JB: Safari and IE don't support webcam, so we could make a nicer back up maybe?

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected