-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
89 lines (80 loc) · 2.54 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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>EKA Live Streaming</title>
<!--
Uses the latest versions of video.js and videojs-http-streaming.
To use specific versions, please change the URLs to the form:
<link href="https://unpkg.com/[email protected]/dist/video-js.css" rel="stylesheet">
<script src="https://unpkg.com/[email protected]/dist/video.js"></script>
<script src="https://unpkg.com/@videojs/[email protected]/dist/videojs-http-streaming.js"></script>
-->
<link href="css/reset.css" rel="stylesheet">
<link href="css/video-js.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<div id="container">
<h1>EKA Live Streaming</h1>
<video-js id="player" class="vjs-default-skin" controls preload="auto" width="640" height="268">
<!-- <source src="/hls/stream.m3u8" type="application/x-mpegURL"> -->
</video-js>
<div id="status-off-air">
<img src="img/off-air.png" alt="Off Air">
<p class="off-air">No stream available</p>
</div><!--status-off-air-->
<div id="status-on-air">
<p class="on-air"><span>LIVE</span> Streaming now!</p>
</div><!--status-on-air-->
</div><!--container-->
<script src="js/video.js"></script>
<script src="js/videojs-http-streaming.js"></script>
<script>
checkStreamExists();
var tryAgain;
// Check if stream exists
function checkStreamExists() {
console.log('Checking if its streaming now LIVE now');
var request = new XMLHttpRequest();
var status;
request.open("GET", "/hls/stream.m3u8", true);
request.send();
request.onload = function () {
console.log(request);
if (request.status === 200) {
console.log("Found m3u8.. starting to stream");
if (tryAgain) {
clearTimeout(tryAgain);
}
showVideo();
} else {
console.log("m3u8 file not found");
tryAgain = setTimeout(checkStreamExists, 10 * 1000);
}
}
}
function showVideo() {
document.getElementById('status-off-air').style.display = 'none';
document.getElementById('status-on-air').style.display = 'block';
var player = videojs('#player', {
autoplay: true,
html5: {
hlsjsConfig: {
debug: true,
// Other hlsjsConfig options provided by hls.js
p2pConfig: {
logLevel: true,
live: false, // set to true in live mode
}
}
}
});
player.src({
type: "application/x-mpegURL",
src: "/hls/stream.m3u8"
});
}
</script>
</body>
</html>