forked from phoboslab/jsmpeg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
238 lines (229 loc) · 7.04 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<!DOCTYPE html>
<html>
<head>
<!-- <meta name="viewport" content="width=320, initial-scale=1"/> -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type='text/javascript' src="http://hammerjs.github.io/dist/hammer.min.js"></script>
<title>jsmpeg streaming</title>
<!-- <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css"> -->
<style type="text/css">
body{
margin:0;
background-color: #444;
text-align: center;
/* Basic Grey */
}
.basic-grey {
margin-left:auto;
margin-right:auto;
max-width: 500px;
background: #333;
padding: 25px 15px 25px 10px;
font: 12px Georgia, "Times New Roman", Times, serif;
color: #888;
text-shadow: 1px 1px 1px #FFF;
border:1px solid #555;
}
.basic-grey h1 {
font-size: 25px;
padding: 0px 0px 10px 40px;
display: block;
border-bottom:1px solid #E4E4E4;
margin: -10px -15px 30px -10px;;
color: #888;
}
.basic-grey h1>span {
display: block;
font-size: 11px;
}
.basic-grey label {
display: block;
margin: 0px;
}
.basic-grey label>span {
float: left;
width: 20%;
text-align: right;
padding-right: 10px;
margin-top: 10px;
color: #888;
}
.basic-grey input[type="text"], .basic-grey input[type="email"], .basic-grey textarea, .basic-grey select {
border: 1px solid #DADADA;
color: #888;
height: 30px;
margin-bottom: 16px;
margin-right: 6px;
margin-top: 2px;
outline: 0 none;
padding: 3px 3px 3px 5px;
width: 70%;
font-size: 12px;
line-height:15px;
box-shadow: inset 0px 1px 4px #ECECEC;
-moz-box-shadow: inset 0px 1px 4px #ECECEC;
-webkit-box-shadow: inset 0px 1px 4px #ECECEC;
}
.basic-grey textarea{
padding: 5px 3px 3px 5px;
}
.basic-grey select {
background: #FFF url('down-arrow.png') no-repeat right;
background: #FFF url('down-arrow.png') no-repeat right);
appearance:none;
-webkit-appearance:none;
-moz-appearance: none;
text-indent: 0.01px;
text-overflow: '';
width: 70%;
height: 35px;
line-height: 25px;
}
.basic-grey textarea{
height:100px;
}
.basic-grey .button {
background: #E27575;
border: none;
padding: 10px 25px 10px 25px;
color: #FFF;
box-shadow: 1px 1px 5px #B6B6B6;
border-radius: 3px;
text-shadow: 1px 1px 1px #9E3F3F;
cursor: pointer;
}
.basic-grey .button:hover {
background: #CF7A7A
}
#videoCanvas {
/* Always stretch the canvas to 640x480, regardless of its
internal size. */
width: 640px;
height: 480px;
}
#videoCanvas:fullscreen {
/* Always stretch the canvas to 640x480, regardless of its
internal size. */
width: 100%;
height: inherit;
}
div {
text-align: center;
}
</style>
</head>
<body>
<!-- The Canvas size specified here is the "initial" internal resolution. jsmpeg will
change this internal resolution to whatever the source provides. The size the
canvas is displayed on the website is dictated by the CSS style.
-->
<canvas id="videoCanvas" width="320" height="240">
<p>
Please use a browser that supports the Canvas Element, like
<a href="http://www.google.com/chrome">Chrome</a>,
<a href="http://www.mozilla.com/firefox/">Firefox</a>,
<a href="http://www.apple.com/safari/">Safari</a> or Internet Explorer 10
</p>
</canvas>
<div>
<form id='btnContainer' class="basic-grey">
<p>
<input type='button' class='button' id='btnOn' value="Licht aan" />
<input type='button' class='button' id='btnOff' value="Licht uit" /><br>
<input type='range' min=0 max=255 value=255 id="rngBri"/>
</p>
</form>
</div>
<iframe src="http://www.ustream.tv/embed/13371060?wmode=direct" style="border: 0 none transparent;" webkitallowfullscreen allowfullscreen frameborder="no" width="480" height="302"></iframe><br />
<script type="text/javascript" src="jsmpg.js"></script>
<script type="text/javascript">
// Setup the WebSocket connection and start the player
var client = new WebSocket( 'ws://84.106.64.128:8084/' );
// var client = new WebSocket( 'ws://localhost:8084/' );
var canvas = document.getElementById('videoCanvas');
var player = new jsmpeg(client, {'canvas':canvas});
var d = new Date();
var messagePerSecond = 3;
var rate = 1000/messagePerSecond;
var last=d.getTime();
var socket = new WebSocket('ws://84.106.64.128:5002/');
// var socket = new WebSocket('ws://localhost:5002/');
btnOn = document.getElementById("btnOn");
btnOff = document.getElementById("btnOff");
rngBri = document.getElementById("rngBri");
btnTakePic = document.getElementById("btnTakePic");
function launchIntoFullscreen(element) {
if(element.requestFullscreen) {
element.requestFullscreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if(element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}
function setBrightness(force){
var bri = rngBri.value;
var t = (new Date()).getTime();
if(force || t > last+rate){
console.log(bri);
last = t;
socket.send(JSON.stringify({
type: 'lights',
data: 'on',
bri: bri
}));
}
}
btnOn.onclick = function() {
console.log('test');
socket.send(JSON.stringify({
type: 'lights',
data: 'on',
bri: rngBri.value
}));
}
btnOff.onclick = function() {
console.log('test');
socket.send(JSON.stringify({
type: 'lights',
data: 'off'
}));
}
rngBri.oninput = function(event){
setBrightness(false);
}
rngBri.onchange = function(event){
setBrightness(true);
}
var changeHandler = function(event){
if(event.target.style.width == screen.width+"px"){
console.log("exit fullscreen");
canvas.style.width = "640px";
canvas.style.height = "480px";
}else{
console.log("enter fullscreen");
var w =screen.width+"px";
var h =screen.height+"px";
if(w>h){
w = h * 640/480
}else{
h = w / (640/480);
}
canvas.style.width = w +"px";
canvas.style.height = h+"px";
};
console.log(event);
}
document.addEventListener("fullscreenchange", changeHandler, false);
document.addEventListener("webkitfullscreenchange", changeHandler, false);
document.addEventListener("mozfullscreenchange", changeHandler, false);
Hammer(canvas).on('doubletap', function(){
console.log('tap');
launchIntoFullscreen(canvas);
// canvas.width
})
</script>
</body>
</html>