-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
83 lines (76 loc) · 2.62 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
<html>
<head>
<title>WBS + Hypercast</title>
<style>
.viewVideo {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: black;
}
.viewUrl {
position: absolute;
left: 0px;
top: 0px;
background: white;
color: black;
border: white solid 6px;
border-radius: 6px;
z-index: 2;
font-size: 8px;
}
</style>
</head>
<body>
<h1 id="intro">Click Anywhere to Start</h1>
</body>
<script src="static/wbs.js"></script>
<script src="static/hypercast.js"></script>
<script>
window.addEventListener('click', () => {
var intro = document.querySelector('#intro')
if (!intro) return
intro.parentElement.removeChild(intro)
var viewURL = getParameterByName('view', window.location.href)
if (viewURL) {
if (!window.DatArchive) window.alert("This application only works in Beaker Browser!")
var videoElement = Hypercast.view(viewURL)
videoElement.className = 'viewVideo'
videoElement.autoplay = true
videoElement.oncanplay = function () {
videoElement.play()
}
document.body.appendChild(videoElement)
} else {
var div = document.createElement('div')
document.body.appendChild(div)
var wbs = new WBS(div)
wbs.on('stream', function (stream) {
if (!window.DatArchive) window.alert("This application only works in Beaker Browser!")
async function go () {
var url = await Hypercast.broadcast(stream)
var alert = document.createElement('div')
alert.className = 'viewUrl'
alert.innerHTML = (window.location.href + '?view=' + url)
document.body.appendChild(alert)
}
go()
})
wbs.on('stopstream', function () {
document.body.removeChild(document.querySelector('.viewUrl'))
})
}
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
})
</script>
</html>