-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpg.php
65 lines (62 loc) · 1.41 KB
/
pg.php
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
<?
header("Access-Control-Allow-Origin: *");
header("X-Frame-Options: ALLOWALL");
?>
<html>
<head>
<title>VATC</title>
<script src="swrtc.js"></script>
<script>
var webrtc;
function connectFrequency(freq) {
if (webrtc) {
webrtc.disconnect();
webrtc = null;
}
if (freq.length < 5) {
return;
}
var room = "geofs-freq-" + freq;
webrtc = new SimpleWebRTC({
// we don't do video
localVideoEl: 'localAudio',
remoteVideosEl: 'remoteAudios',
autoRequestMedia: true,
enableDataChannels: false,
media: {
audio: true,
video: false
}
});
webrtc.on('readyToCall', function () {
if (room) {
webrtc.joinRoom(room, function (err, res) {
if (err) {
return;
}
webrtc.mute();
window.speechSynthesis.speak(new SpeechSynthesisUtterance("Connected to the new frequency"));
});
}
});
}
if (window.location.href.split('?')[1].length > 4)
connectFrequency(window.location.href.split('?')[1]);
window.addEventListener("message", function(event) {
if (event.data == "talk") {
webrtc.unmute();
}
else if (event.data == "notalk") {
webrtc.mute();
}
else if (event.data.frequency) {
connectFrequency(event.data.frequency);
}
});
</script>
</head>
<body>
<audio id="localAudio" controls oncontextmenu="return false;" volume="0" disabled></audio>
<div id="remoteAudios"></div>
</body>
</html>