-
Notifications
You must be signed in to change notification settings - Fork 23
/
sendstream.html
46 lines (41 loc) · 1.18 KB
/
sendstream.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
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
<script src="libs/adapter.min.js" ></script>
<script src="webrtcstreamer.js" ></script>
<script src="webrtcconfig.js" ></script>
<script>
let video = "";
let options = webrtcConfig.options;
if (location.search.slice(1)) {
if (typeof URLSearchParams != 'undefined') {
var params = new URLSearchParams(location.search);
if (params.has("video")) {
video = params.get("video");
}
if (params.has("options")) {
options = params.get("options");
}
}
}
window.onload = function() {
this.webRtcServer = new WebRtcStreamer("remotevideo", webrtcConfig.url);
navigator.mediaDevices.getUserMedia({video: true, audio: true}).then(stream => {
var videoElement = document.getElementById("localvideo");
videoElement.srcObject = stream;
videoElement.play();
this.webRtcServer.connect(video, "", options, stream)
})
}
window.onbeforeunload = function() { this.webRtcServer.disconnect() }
</script>
</head>
<body>
<div>
<video id="localvideo" ></video>
</div>
<div>
<video id="remotevideo" muted playsinline></video>
</div>
</body>
</html>