-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
58 lines (47 loc) · 1.32 KB
/
index.html
File metadata and controls
58 lines (47 loc) · 1.32 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Player</title>
</head>
<body>
<img id="player" />
<br />
<button onclick="manualStart()">Start</button>
<button onclick="manualStop()">Stop</button>
</body>
<script src="mjpeg.js"></script>
<script>
function onErr(status, payload) {
console.error(status);
console.error(payload);
player.stop();
}
function onStarted() {
console.log('Started');
}
function onStopped() {
console.warn('Stopped');
// Comment bellow lines to keep last image presented
const container = document.getElementById("player");
container.removeAttribute("src");
}
function onFrame(frame) {
console.log('New frame',frame);
}
function onLoad(e) {
e.preventDefault();
e.stopPropagation();
console.log('Image loaded',e);
if (e.target instanceof Image) e.target.onload = undefined;
}
function manualStart() {
if (player) player.start();
}
function manualStop() {
if (player) player.stop();
}
var player = new MJPEG.Player("player", "http://<host>:<port>/<path>", "<username>", "<password>", {onError: onErr, onStart: onStarted, onStop: onStopped, onFrame: onFrame, onLoad: onLoad});
player.start();
</script>
</html>