-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.html
101 lines (86 loc) · 3.24 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>WebRTC Streaming</title>
<link rel="stylesheet" href="./styles.css">
</head>
<body>
<h1>SplitSound v0.0.-1</h1>
<hr><br>
<form onsubmit="return false;">
<div><b>Room name: </b></div>
<input type="text" id="connectRoom" value="test">
<div id="streamFrom">
<div><b>Stream from: </b></div>
<div class="inputOptions">
<select id="streamFromOptions">
<option value="none">None</option>
<option value="file">File</option>
<option value="mic">Microphone</option>
<option id="fromDesktop" value="desktop">Desktop Capture (Windows only)</option>
</select>
</div>
</div>
<div>
<button id="connectButton">Connect</button>
</div>
</form>
<h2>Local:</h2>
<h3>ID: <span id="socketId">disconnected</span></h3>
<div id="localMedia">
<video id="localVideo" class="localVideo" autoplay controls muted></video>
</div>
<select id="vizualizerOptions">
<option value="line">Line</option>
<option value="bar">Bar</option>
</select><br><br>
<canvas id="visualizer" width="512" height="300"></canvas>
<h2>Remote Connections:</h2>
<div id="remoteMedia"></div>
<script type="text/javascript" src="./node_modules/socket.io-client/dist/socket.io.js"></script>
<script type="text/javascript" src="./lib.js"></script>
<script type="text/javascript">
let socket = new Socket('symboxtra.dynu.net', 8080);
document.getElementById('connectButton').addEventListener('click', async () => {
// Leave any old rooms
socket.leaveAllRooms();
let source = document.getElementById('streamFromOptions').value;
switch (source) {
case 'file':
await setupLocalMediaStreamsFromFile('./test_file.mp3');
break;
case 'mic':
// Disable the constraints that exclude microphone
delete mediaStreamConstraints.audio.mandatory.chromeMediaSource;
if (showVideo) {
// Can't do screen capture without screen audio
mediaStreamConstraints.video = true;
} else {
mediaStreamConstraints.video = false;
}
await setupLocalMediaStreams();
break;
case 'desktop':
await setupLocalMediaStreams();
break;
case 'none':
default:
receiverOnly = true;
break;
}
let room = document.getElementById('connectRoom').value;
socket.joinRoom(room);
});
document.addEventListener('keyup', (e) => {
if (e.which === 123) {
if (isElectron) {
require('remote').getCurrentWindow().toggleDevTools();
}
} else if (e.which === 116) {
location.reload();
}
});
</script>
</body>
</html>