-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
52 lines (44 loc) · 1.66 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HLS</title>
<meta name="description" content="A simple HLS.js implementation">
<link rel="stylesheet" href="TopLevelVideoDocument.css">
<script src="hls.min.js"></script>
</head>
<body>
<video id="video" autoplay controls></video>
<script type="text/javascript" src="TopLevelVideoDocument.js"></script>
<script>
var hls = new Hls();
hls.on(Hls.Events.MEDIA_ATTACHED, function () {
console.log('video and hls.js are now bound together !');
});
hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
console.log('manifest loaded, found ' + data.levels.length + ' quality level');
});
hls.on(Hls.Events.ERROR, function (event, data) {
if (data.fatal) {
switch (data.type) {
case Hls.ErrorTypes.MEDIA_ERROR:
console.log('fatal media error encountered, try to recover');
hls.recoverMediaError();
break;
case Hls.ErrorTypes.NETWORK_ERROR:
console.error('fatal network error encountered', data);
break;
default:
hls.destroy();
break;
}
}
});
var video = document.getElementById('video');
hls.attachMedia(video);
hls.loadSource('https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8');
video.play();
</script>
</body>
</html>