-
Notifications
You must be signed in to change notification settings - Fork 1
/
hls_player.html
40 lines (36 loc) · 1.43 KB
/
hls_player.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HLS Player</title>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
</head>
<body>
<video id="video-player" controls autoplay style="width: 100%;"></video>
<script>
const urlParams = new URLSearchParams(window.location.search);
const url = urlParams.get('videoUrl');
var video = document.getElementById('video-player');
let hls = null;
if (hls) { hls.destroy(); }
var config = {
//debug: debug,
xhrSetup: function (xhr, url) {
xhr.withCredentials = true; // do send cookies
},
fetchSetup: function (context, initParams) {
// Always send cookies, even for cross-origin calls.
initParams.credentials = 'include';
return new Request(context.url, initParams);
},
}
hls = new Hls(config);
hls.loadSource(url);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function () {
video.play();
});
</script>
</body>
</html>