blob: 7bb2ee5c5d4c989d80e695e145fe3402db52b054 (
plain)
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
|
<!DOCTYPE html>
<html>
<head>
<title>Live Streaming</title>
</head>
<body>
<img id="frame" src="">
<h1>Streaming. Live.</h1>
<script>
let ws = new WebSocket("ws://127.0.0.1:8880/{{client_id}}/{{camera_id}}");
let image = document.getElementById("frame");
let currentUrl = null;
ws.onmessage = function(event) {
if (currentUrl) {
URL.revokeObjectURL(currentUrl);
}
currentUrl = URL.createObjectURL(event.data);
image.src = currentUrl;
};
ws.onclose = function(event) {
console.log("WebSocket closed:", event);
};
ws.onerror = function(event) {
console.log("WebSocket error:", event);
};
window.addEventListener('beforeunload', function() {
ws.close();
});
</script>
</body>
</html>
|