-
Notifications
You must be signed in to change notification settings - Fork 4
/
screenshare.html
110 lines (92 loc) · 2.95 KB
/
screenshare.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html>
<head>
<title>Screensharing</title>
<style type="text/css">
html, body {
background-color: #111;
text-align: center;
}
</style>
</head>
<body>
<canvas id="video-canvas"></canvas>
<script type="text/javascript" src="vendor/jsmpeg/jsmpeg.min.js"></script>
<script type="text/javascript">
var canvas = document.getElementById('video-canvas');
var url = 'ws://'+document.location.hostname+':8082/';
var player = new JSMpeg.Player(url, {canvas: canvas});
</script>
<script src="src/wire.js"></script>
<script src="src/connection.js"></script>
<script src="src/transmitter.js"></script>
<script src="src/transmitter_example.js"></script>
<script type="text/javascript">
var target = 'ws://' + location.hostname + ':8081/touchpad';
var connection = new Connection(target, handler);
connection.open();
activateTouch();
var scale = '.75';
var mode = 'sr';
function screenshare() {
mode = 'sr';
resizeStream();
}
function resizeStream() {
connection.sendType(mode, {
scale: scale
});
// TODO server should broadcast request to resize
setTimeout(() => {
player.video.hasSequenceHeader = false
}, 500);
}
function webcam() {
mode = 'wr';
resizeStream();
}
function setScale(s) {
scale = s;
resizeStream();
}
function ask() {
var input = prompt('Say something');
if (input) connection.sendType('rt', {
text: input
})
}
function activate(target) {
target.addEventListener('keydown', (e) => {
console.log('down', e);
connection.send('key: ' + e.key + ' code: ' + e.code);
});
target.addEventListener('keyup', (e) => {
console.log('up', e);
});
}
</script>
<div style="position: fixed; bottom: 0; left: 0; z-index: 50; padding: 10px;">
<button onclick="screenshare()">Request Screenshare</button>
<button onclick="webcam()">Request Webcam</button>
<!--<button onclick="setScale('double')">Zoom x2</button>-->
<button onclick="setScale('')">Zoom x1</button>
<button onclick="setScale('.75')">Zoom x0.75</button>
<button onclick="setScale('half')">Zoom x0.5</button>
<button onclick="setScale('quarter')">Zoom x0.25</button>
<button onclick="setScale('720p')">Zoom 720p</button>
<button onclick="ask()">Type something</button>
<input onfocus="activate(this)"/>
<textarea></textarea>
<!--TODOS
<button>Left</button>
<button>Right</button>
<button>Up</button>
<button>Down</button>
Enter
Backspace
Cmd-Tab
ADD mini typeboard here.
-->
</div>
</body>
</html>