-
Notifications
You must be signed in to change notification settings - Fork 454
Expand file tree
/
Copy pathindex.html
More file actions
81 lines (70 loc) · 1.62 KB
/
index.html
File metadata and controls
81 lines (70 loc) · 1.62 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<html>
<link rel="shortcut icon" href="about:blank" />
<style>
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
h3 {
text-align: center;
}
video {
display: block;
margin: 0 auto;
}
img {
display: block;
margin: 0 auto;
}
body {
display: flex;
flex-direction: column;
}
#content {
flex: 1;
}
#footer {
text-align: center;
width: 100%;
}
</style>
<body>
<div id="content"></div>
<footer id="footer"></footer>
<script src="hls.js"></script>
<script>
fetch('version')
.then(response => response.text())
.then(version => {
document.getElementById("footer").innerHTML = "<p><a href='https://github.com/mpromonet/v4l2rtspserver'>v4l2rtspserver</a>"
+ " " + version + "</p>";
});
fetch('streamlist')
.then(response => response.json())
.then(streamList => {
const content = document.getElementById("content")
streamList.forEach(stream => {
const [name, formats] = Object.entries(stream)[0];
const title = document.createElement("h3");
title.innerText = name;
content.appendChild(title)
if (formats.some(fmt => fmt.toUpperCase().includes("JPEG"))) {
const img = document.createElement("img");
img.src = "/snapshot?" + name;
content.appendChild(img)
}
else if (formats.some(fmt => fmt.toUpperCase().includes("MP2T"))) {
const video = document.createElement("video");
content.appendChild(video)
const hls = new Hls();
hls.loadSource(stream + ".m3u8");
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function () { video.play(); });
}
})
});
</script>
</body>
</html>