-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
59 lines (54 loc) · 1.95 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<html>
<head>
<script src="http://cdn.binaryjs.com/0/binary.js"></script>
</head>
<body>
<script>
// Connect to Binary.js server
var client = new BinaryClient('ws://10.0.1.13:9999');
var rows = 0;
// Received new stream from server!
client.on('all', function() {
console.log('[ STUFF IS HAPPENING ]', arguments);
});
var tempcanvas = document.createElement('canvas');
tempcanvas.height = 768;
tempcanvas.width = 1024;
document.body.appendChild(tempcanvas);
var tempcontext = tempcanvas.getContext('2d');
client.on('stream', function(stream, meta){
stream.on('data', function(data){
// 4096 bytes
var bytes = new Uint8Array(data),
// blob = new Blob(data),
// otherBytes = newUnit8Array(blob),
image = tempcontext.createImageData(tempcanvas.width, tempcanvas.height);
for (var i=0; i<image.length; i++) {
image.data[i] = bytes[i];
}
tempcontext.putImageData(image, 0, rows);
});
// stream.on('data', function(data){
// console.log('[ DATA ARRIVE ] ', data);
// var bytes = new Uint8Array(data),
// src = (window.URL || window.webkitURL).createObjectURL(new Blob(data)),
// img = new Image(src);
// tempcontext.putImageData(bytes, 0, 0);
// });
stream.on('close', function(){
console.log('[ STREAM END ]');
window.results = tempcontext.getImageData(0,0,1024,768).data;
for (var i = 0; i < 300000; i++) {
if (window.results[i] !== 0) console.log('HOLY SMOKES IT WORKS');
}
// // Display new data in browser!
// var video = document.createElement("video");
// video.src = (window.URL || window.webkitURL).createObjectURL(new Blob(parts));
// document.body.innerHTML = "";
// document.body.appendChild(video);
// lastFrame = video;
});
});
</script>
</body>
</html>