-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlive.html
75 lines (65 loc) · 2.07 KB
/
live.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Watch Live Stream</title>
<!-- Import the stylesheet -->
<link rel="stylesheet" href="/style.css" />
<script src="https://cdn.tailwindcss.com"></script>
<!-- Import the javascript file -->
<script src="/script.js" defer></script>
<script
defer
src="https://ajax.googleapis.com/ajax/libs/shaka-player/3.3.2/shaka-player.compiled.js"
></script>
<script defer>
// get the id parameter from the url link for the manifestUri
let params = new URL(document.location).searchParams;
let streamId = params.get('id');
const manifestUri = `https://bifrost.inlive.app/streams/${streamId}/manifest.mpd`;
function initApp() {
shaka.polyfill.installAll();
if (shaka.Player.isBrowserSupported()) {
initPlayer();
} else {
console.error('Browser not supported!');
}
}
async function initPlayer() {
const video = document.getElementById('video');
const player = new shaka.Player(video);
window.player = player;
player.addEventListener('error', onErrorEvent);
try {
await player.load(manifestUri);
console.log('The video has now been loaded!');
} catch (e) {
onError(e);
}
}
function onErrorEvent(event) {
onError(event.detail);
}
function onError(error) {
console.error('Error code', error.code, 'object', error);
}
document.addEventListener('DOMContentLoaded', initApp);
</script>
</head>
<body>
<h1 class="text-center text-[28px] font-bold my-2">Watch Live Stream</h1>
<hr />
<div class="flex justify-center items-center">
<video
autoplay
muted
controls
playsinline
id="video"
class="w-3/4 border rounded-xl my-4"
></video>
</div>
</body>
</html>