forked from steely-glint/unrupt-demo
-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
720 lines (664 loc) · 34.6 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
<!doctype html>
<html lang="en">
<head>
<title>Podcast call recorder</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
</style>
</head>
<body>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" crossorigin="anonymous"></script>
<script src="https://pi.pe/iot/js/qrcode.js"></script>
<a href="index.html"><h1 id="title" class="text-center">Podcast interview recorder</h1></a>
<div class="container">
<h2>Role: <span class="badge badge-primary" id="role"></span></h2>
<h2>Status: <span class="badge badge-primary" id="status"></span></h2>
</div>
<div class="container">
<div id="chosenAction" class="row">
<button id="mute" type="button" class="btn btn-primary btn-lg"><i id="muteIcon" class="fa fa-microphone fa-2x" aria-hidden="true"></i></button>
<button id="stopCall" type="button" class="btn btn-primary btn-lg"><i id="stopIcon" class="fa fa-stop fa-2x" aria-hidden="true"></i></button>
</div>
<div>Duration <span class="badge badge-error" id="duration"></span></div>
<div class="alert alert-danger" id="packetLoss">
<strong id="countZero"></strong>% packet loss detected.
</div>
<div class="alert alert-info" id="statsZone">
local <strong id="local"></strong><br/>
<strong id="delay"></strong> sec delay<br/>
remote <strong id="remote"></strong><br/>
</div>
</div>
<div id="share" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Send this url to the interviewee. </h5>
</div>
<div class="modal-body" id="shareQR">
<p>Share this URL to request an interview</p>
</div>
<div class="modal-footer">
<button id="shareDone" type="button" class="btn btn-secondary" data-dismiss="modal" onclick="shared();">Done</button>
</div>
</div>
</div>
</div>
<div id="accept" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Accept an interview</h5>
</div>
<div class="modal-body">
<p>Click 'accept' to start the call.</p>
</div>
<div class="modal-footer">
<button id="callAccept" type="button" class="btn btn-secondary" data-dismiss="modal" onclick="accepted();">Accept</button>
</div>
</div>
</div>
</div>
<div id="nowebrtc" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Sorry</h5>
</div>
<div class="modal-body">
<p>Unfortunately the browser you are using does not support WebRTC.</p>
<p>Please retry using Safari on iOS, Chrome on Android, FireFox on Android, or pretty much any modern browser on a laptop.</p>
</div>
<div class="modal-footer">
<button id="sadder" type="button" class="btn btn-secondary" data-dismiss="modal" >Accept</button>
</div>
</div>
</div>
</div>
<div id="nomediaapi" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Sorry</h5>
</div>
<div class="modal-body">
<p>Unfortunately the browser you are using does not support the media recorder API.</p>
<p>Please try hosting the call with Chrome or FireFox or Edge.</p>
<p>Your guest can use any modern browser</p>
</div>
<div class="modal-footer">
<button id="sad" type="button" class="btn btn-secondary" data-dismiss="modal" >Accept</button>
</div>
</div>
</div>
</div>
<div id="facebookapp" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Sorry</h5>
</div>
<div class="modal-body">
<p>Unfortunately the Facebook apps block webRTC.</p>
<p>Please try hosting the call with Chrome or FireFox or Edge.</p>
<p>Go to <pre>https://rendezvous.show/</pre> outside the Facebook or instagram app.</p>
<p>You may be able to do this from the three dot menu on the top right of your screen.</p>
<p>Your guest can use any modern browser e.g. Chrome or FireFox or Edge or Safari</p>
</div>
<div class="modal-footer">
<button id="sader" type="button" class="btn btn-secondary" data-dismiss="modal" >Accept</button>
</div>
</div>
</div>
</div>
<audio id="them" style="display: none" autoplay> </audio>
<video id="nosleep" width="100" playsinline muted>
Antisleep video.
</video>
<footer><span>See our <a href="https://github.com/pipe/podcall">Github</a> for source code</span>
<span>See also <a href="https://rendezvous.berlin/privacy-policy.html">Privacy</a>
and <a href="https://pi.pe/Impressum/index.html">Impressum</a></span>
</footer>
<script>
var properties = {
websocketURL: "wss://pi.pe/websocket/?finger=" // where to find the redezvous server.
};
var pc; // actual peer connection to our friend
var socket; // used to set up connection with our peer.
var mid;
var fid;
var cid;
var myac;
var initiator;
var lcandyStash = [];
var rcandyStash = [];
var localStream;
var dcomp;
var recorder;
var chunks = [];
var saved = false;
var startRecTime = 0;
var lastLoss = 0;
var lastRecv =0;
var softstereo = true;
var join;
var mute = false;
var peerConnectionOfferAnswerCriteria = {offerToReceiveAudio: true, offerToReceiveVideo: false };
var AudioContext = window.AudioContext || window.webkitAudioContext;
// message stuff - used to create direct connection to peer over WEBRTC
function tweakSDP(sdp){
var lines = sdp.split("\r\n");
for (var i=0;i<lines.length;i++){
line = lines[i];
if (line.startsWith("a=fmtp:111")){
lines[i]= "a=fmtp:111 minptime=10; ptime=60; useinbandfec=1";
}
}
return (lines.join("\r\n"));
}
function loadProps() {
var that = {configUrl: "pipeconfig.json"};
var promise = new Promise(function (resolve, reject) {
var xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open('GET', that.configUrl, true);
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
var pipeconfig = JSON.parse(xobj.responseText);
console.log("Config is " + xobj.responseText);
if (pipeconfig.ice) {
that.configuration = pipeconfig.ice;
console.log("Set ICE params " + JSON.stringify(that.configuration));
}
if (pipeconfig.wsurl) {
that.wsurl = pipeconfig.wsurl;
console.log("Set wsurl " + JSON.stringify(that.wsurl));
}
resolve(that);
}
};
xobj.send(null);
});
return promise;
}
function messageDeal(event){
//console.log("message is ", event.data);
var data = JSON.parse(event.data);
console.log("message data is ", data);
if (data.to != mid){
alert("message mixup");
}
switch (data.type) {
case "offer":
if (fid == null) {
fid = data.from;
}
if(recorder && initiator){
stopCall();
document.location = document.location;
} else {
pc.setRemoteDescription(data).then(_ =>
pc.createAnswer(peerConnectionOfferAnswerCriteria).then(ans => {
ans.sdp = tweakSDP(ans.sdp);
pc.setLocalDescription(ans).then(_ =>
sendMessage(fid, mid, "answer", ans.sdp)
)
})
)
.catch((e) => console.log("set Remote offer error", e));
}
break;
case "answer":
pc.setRemoteDescription(data)
.then( _ => {
//$("#action").text("hangup");
})
.catch(e => console.log("set Remote answer error", e) );
break;
case "candidate":
var jc = {
sdpMLineIndex: 0,
candidate: data.sdp
};
console.log("adding candidate ", jc);
var nc = new RTCIceCandidate(jc);
pc.addIceCandidate(nc)
.then( _ => console.log("added remote candidate"))
.catch((e) => console.log("couldn't add candidate ", e));
break;
}
}
function sendMessage(to,from,type,data){
var messageJ = {
to:to,
from:from,
type:type,
sdp:data
};
var message = JSON.stringify(messageJ);
console.log("sending ", messageJ);
socket.send(message);
}
// button actions
function startCall(cid){
lcandyStash = [];
rcandyStash = [];
fid = cid;
pc.createOffer(peerConnectionOfferAnswerCriteria)
.then(desc => {
console.log("offer created",);
$("#status").text("Making call to host");
desc.sdp = tweakSDP(desc.sdp);
pc.setLocalDescription(desc).then( d => sendMessage(fid, mid, desc.type, desc.sdp));
})
.catch(e => console.log("offer not created due to ", e) );
}
function saveData(blob) {
var fileName = 'distributedFuture-'+new Date().toISOString() + '.webm';
console.log("Save data ?");
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
console.log("saving wav blob as " + fileName);
url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
saved = true;
$("#status").text("Call saved as "+fileName);
}
function stopCall(){
localStream.getAudioTracks()[0].stop();
if (initiator) {
recorder.stop();
} else {
clearInterval(recorder);
}
// save file here....
$("#status").text("Call ended.");
}
// mute management
function setMute(m){
var mi = $("#muteIcon");
mute = m;
if (m){
mi.removeClass("fa-microphone");
mi.addClass("fa-microphone-slash");
} else {
mi.removeClass("fa-microphone-slash");
mi.addClass("fa-microphone");
}
var audioTracks = localStream.getAudioTracks();
if (audioTracks[0]) {
audioTracks[0].enabled = !m;
}
}
function repaintDuration(){
var diff = Date.now() - startRecTime;
console.log ("data on at "+diff);
var mins = Math.floor(diff / 60000);
var secs = Math.floor((diff % 60000) / 1000);
$("#duration").text(""+mins+":"+secs);
}
function checkLoss(){
pc.getReceivers()[0].getStats().then(
function(rs) {
rs.forEach( function (d){
if(d.type ==="inbound-rtp"){
var recvd = d.packetsReceived;
var lost = d.packetsLost;
if (lost > lastLoss){
$("#packetLoss").show();
var diffl = lost - lastLoss;
var diffp = recvd -lastRecv;
var pct = Math.ceil(100.0 * diffl /diffp);
$("#countZero").text(""+pct);
} else {
$("#packetLoss").hide();
}
lastLoss = lost;
lastRecv = recvd;
}
if ((d.type ==="candidate-pair")&&(d.nominated)){
$("#delay").text(""+d.currentRoundTripTime);
}
if (d.type === "remote-candidate"){
$("#remote").text(d.candidateType);
}
if (d.type === "local-candidate"){
$("#local").text(d.candidateType);
}
}
)
});
}
// called when webRTC presents us with a fresh remote audio stream
function addStream(stream,kind) {
if (!kind) {
kind = "audio/video";
}
$("#status").text("Call connected.");
console.log("got new stream" + stream + " kind =" + kind);
if (kind.indexOf("audio")!= -1) {
document.getElementById("them").srcObject = stream;
var peer = myac.createMediaStreamSource(stream);
if (initiator) {
if (softstereo){
let panyou = myac.createStereoPanner();
panyou.pan.value = +0.3;
peer.connect(panyou)
panyou.connect(dcomp);
} else {
let splityou = myac.createChannelSplitter(2); // 2 outputs L and R
peer.connect(splityou);
splityou.connect(join, 1, 1);
// join already connected to dcomp
}
var recStream = myac.createMediaStreamDestination();
recorder = new MediaRecorder(recStream.stream);
dcomp.connect(recStream);
recorder.ondataavailable = function(evt) {
chunks.push(evt.data);
repaintDuration();
};
recorder.onstop = function(evt) {
// Make blob out of our blobs, and open it.
var blob = new Blob(chunks, { 'type' : 'audio/ogg; codecs=opus' });
saveData(blob)
};
stream.onremovetrack = function(event) {
console.log( "Removed track : " + event.track.kind + ": " + event.track.label);
};
recorder.start(10000);
} else {
recorder = window.setInterval(repaintDuration,10000);
}
window.setInterval(checkLoss,1000);
startRecTime = Date.now();
// audio together here.
// depends on role
console.log('Audio sample Rate is '+ myac.sampleRate);
$("#chosenAction").show();
$("#statsZone").show();
}
}
// configure local peerconnection and handlers
function setupRTC(){
pc = new RTCPeerConnection(properties.configuration, null);
console.log("created peer connection");
pc.onicecandidate = (e) => {
console.log("local ice candidate", e.candidate);
if (e.candidate != null) {
if (pc.signalingState == 'stable') {
sendMessage(fid, mid, "candidate", e.candidate.candidate);
} else {
console.log("stashing ice candidate");
lcandyStash.push(e.candidate);
}
}
};
pc.oniceconnectionstatechange = (e) => {
console.log("ice state is changed", pc.iceConnectionState);
/*
"new" The ICE agent is gathering addresses or is waiting to be given remote candidates through calls to RTCPeerConnection.addIceCandidate() (or both).
"checking" The ICE agent has been given one or more remote candidates and is checking pairs of local and remote candidates against one another to try to find a compatible match, but has not yet found a pair which will allow the peer connection to be made. It's possible that gathering of candidates is also still underway.
"connected" A usable pairing of local and remote candidates has been found for all components of the connection, and the connection has been established. It's possible that gathering is still underway, and it's also possible that the ICE agent is still checking candidates against one another looking for a better connection to use.
"completed" The ICE agent has finished gathering candidates, has checked all pairs against one another, and has found a connection for all components.
"failed" The ICE candidate has checked all candidates pairs against one another and has failed to find compatible matches for all components of the connection. It is, however, possible that the ICE agent did find compatible connections for some components.
"disconnected" Checks to ensure that components are still connected failed for at least one component of the RTCPeerConnection. This is a less stringent test than "failed" and may trigger intermittently and resolve just as spontaneously on less reliable networks, or during temporary disconnections. When the problem resolves, the connection may return to the "connected" state.
"closed"
*/
if (pc.iceConnectionState === "failed"){
stopCall();
}
};
// specification of WEBRTC is in flux - so we test to see if ontrack callback exists
if ('ontrack' in pc) {
// if so we use it
pc.ontrack = (event) => {
var stream = event.streams[0];
console.log("got remote track ", event.track.kind);
addStream(stream,event.track.kind);
};
} else {
// if not we use add stream instead
pc.onaddstream = (event) => {
var stream = event.stream;
console.log("got remote stream ", stream.kind);
addStream(stream);
}
}
// use this to determine the state of the 'hangup' button and send any candidates we found quickly
pc.onsignalingstatechange = (evt) => {
console.log("signalling state is ", pc.signalingState);
if (pc.signalingState == 'stable') {
var can;
while (can = lcandyStash.pop()) {
console.log("popping candidate off stash")
sendMessage(fid, mid, "candidate", can.candidate);
}
var act = $("#stopCall");
act.click( _ => stopCall() );
window.onbeforeunload = function() {
return !saved ? "If you leave this page you will end the interview." : null;
}
}
};
}
// plumb the local audio together.
function setupAudio() {
myac = new AudioContext();
setNoSleep();
dcomp = myac.createDynamicsCompressor();
var gumConstraints = {audio: true, video: false};
var promise = new Promise(function (resolve, reject) {
navigator.mediaDevices.getUserMedia(gumConstraints)
.then((stream) => {
localStream = stream;
if (initiator) {
let node = myac.createMediaStreamSource(stream);
if (softstereo){
let panme = myac.createStereoPanner();
panme.pan.value = -0.3;
node.connect(panme);
panme.connect(dcomp);
} else {
let splitme = myac.createChannelSplitter(2); // 2 outputs L and R
join = myac.createChannelMerger(2); // nominally 2 inputs L and R
node.connect(splitme);
splitme.connect(join, 0, 0)
join.connect(dcomp);
}
}
if (pc.addTrack) {
stream.getTracks().forEach(track => {
pc.addTrack(track, stream);
console.log("added local track ", track.id, track.kind);
});
} else {
pc.addStream(stream);
console.log("added local stream");
}
resolve(false);
})
.catch((e) => {
console.log('getUserMedia() error:' + e);
reject(e);
});
});
return promise;
}
function shared() {
setupRTC();
setupAudio().then(_ => {
console.log("ready for offer");
$("#status").text("Waiting for guest.");
});
}
function accepted() {
setupRTC();
setupAudio().then(_ => {
console.log("ready for offer");
$("#status").text("Mic available");
startCall(cid)
});
}
// decide who we are initiator or recpient.
// notice that the actual call goes in the reverse direction
// the recipient of the invite actually creates the audiobearing peerconnection
// the initiator then accepts this audio - This allows the initiator the chance to
// change their mind, if their circumstances have changed since the invite was sent.
function setRole() {
cid = $.getUrlVar("podcastId");
mid = localStorage['podcastId'];
//var act = $("#action");
if (!mid) {
var array = new Uint32Array(8);
window.crypto.getRandomValues(array);
var hexCodes = [];
for (var i = 0; i < array.length; i ++ ){
// Using getUint32 reduces the number of iterations needed (we process 4 bytes each time)
var value = array[i];
// toString(16) will give the hex representation of the number without padding
var stringValue = value.toString(16);
// We use concatenation and slice for padding
var padding = '00000000';
var paddedValue = (padding + stringValue).slice(-padding.length)
hexCodes.push(paddedValue);
}
mid = hexCodes.join("").toLowerCase();
console.log("mid =", mid);
localStorage['podcastId'] = mid;
}
if (cid == null){
document.location = location.pathname + "?" + "podcastId=" + mid ;
// this has the effect of getting our id into the browser bar -
// making it easy to share etc.
} else {
var qrcode = new QRCode(document.getElementById("shareQR"), {
width: 280,
height: 280,
correctLevel: QRCode.CorrectLevel.L
});
socket = new WebSocket( properties.wsurl + mid);
socket.onmessage = messageDeal;
socket.onopen = (_) => {
var url = document.location.href;
console.log("href = "+url);
if (url) {
qrcode.makeCode(url);
}
initiator = (mid === cid);
var smodal;
if (initiator && !window.MediaRecorder) {
smodal ="#nomediaapi";
} else {
$("#role").text(initiator ? "Host" : "Guest");
$("#status").text("Waiting for connection");
smodal = initiator ? "#share" : "#accept";
}
$(smodal).modal('show');
};
socket.onerror = (e) => {
console.log("can't open websocket", e);
$("#status").text("Internet problems ?");
};
socket.onclose = (e) => {
console.log(" websocket closed", e);
$("#status").text("Server problems ?");
};
}
}
function _addSourceToVideo(element, type, dataURI) {
var source = document.createElement('source');
source.src = dataURI;
source.type = 'video/' + type;
element.appendChild(source);
}
/* find the original at https://github.com/richtr/NoSleep.js/ */
/* brutally butchered version of the above keeps the phone from sleeping becuase it sees a video playing...*/
function setNoSleep() {
var videoEl = document.getElementById("nosleep");
_addSourceToVideo(videoEl, 'webm', 'data:video/webm;base64,GkXfo0AgQoaBAUL3gQFC8oEEQvOBCEKCQAR3ZWJtQoeBAkKFgQIYU4BnQI0VSalmQCgq17FAAw9CQE2AQAZ3aGFtbXlXQUAGd2hhbW15RIlACECPQAAAAAAAFlSua0AxrkAu14EBY8WBAZyBACK1nEADdW5khkAFVl9WUDglhohAA1ZQOIOBAeBABrCBCLqBCB9DtnVAIueBAKNAHIEAAIAwAQCdASoIAAgAAUAmJaQAA3AA/vz0AAA=');
_addSourceToVideo(videoEl, 'mp4', 'data:video/mp4;base64,AAAAIGZ0eXBtcDQyAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAACKBtZGF0AAAC8wYF///v3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE0MiByMjQ3OSBkZDc5YTYxIC0gSC4yNjQvTVBFRy00IE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3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAADDUAAAAAABYCAgAISEAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAABYAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAAUc3RzegAAAAAAAAAGAAAAWAAAAXBzdGNvAAAAAAAAAFgAAAOBAAADhwAAA5oAAAOtAAADswAAA8oAAAPfAAAD5QAAA/gAAAQLAAAEEQAABCgAAAQ9AAAEUAAABFYAAARpAAAEgAAABIYAAASbAAAErgAABLQAAATHAAAE3gAABPMAAAT5AAAFDAAABR8AAAUlAAAFPAAABVEAAAVXAAAFagAABX0AAAWDAAAFmgAABa8AAAXCAAAFyAAABdsAAAXyAAAF+AAABg0AAAYgAAAGJgAABjkAAAZQAAAGZQAABmsAAAZ+AAAGkQAABpcAAAauAAAGwwAABskAAAbcAAAG7wAABwYAAAcMAAAHIQAABzQAAAc6AAAHTQAAB2QAAAdqAAAHfwAAB5IAAAeYAAAHqwAAB8IAAAfXAAAH3QAAB/AAAAgDAAAICQAACCAAAAg1AAAIOwAACE4AAAhhAAAIeAAACH4AAAiRAAAIpAAACKoAAAiwAAAItgAACLwAAAjCAAAAFnVkdGEAAAAObmFtZVN0ZXJlbwAAAHB1ZHRhAAAAaG1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAO2lsc3QAAAAzqXRvbwAAACtkYXRhAAAAAQAAAABIYW5kQnJha2UgMC4xMC4yIDIwMTUwNjExMDA=');
videoEl.addEventListener('loadedmetadata', function () {
console.log("loaded metadata");
if (videoEl.duration <= 1) {
// webm source
videoEl.setAttribute('loop', '');
} else {
// mp4 source
videoEl.addEventListener('timeupdate', function () {
if (videoEl.currentTime > 0.5) {
videoEl.currentTime = Math.random();
}
});
}
});
videoEl.play();
}
function isFacebookApp() {
var ua = navigator.userAgent || navigator.vendor || window.opera;
return (ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1) || (ua.indexOf('Instagram') > -1) ;
}
function isWebrtcSupported() {
// tip of the hat to Janus for this test :
// https://groups.google.com/forum/#!topic/meetecho-janus/lRjYn0C9BYU
// it should detect the horrible mess that is chrome on ios
// and various other ugly captives....
return ('RTCPeerConnection' in window) && ("mediaDevices" in navigator) && ("getUserMedia" in navigator.mediaDevices);
};
// some housekeeping
$.extend({
getUrlVars: function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
getUrlVar: function(name){
return $.getUrlVars()[name];
}
});
$( document ).ready( _ => {
$("#chosenAction").hide();
$("#packetLoss").hide();
$("#statsZone").hide();
if (isFacebookApp()){
$("#status").text("Facebook apps block webrtc in their 'browser' ");
$("#facebookapp").show();
console.log("UGH, facebook. !");
} else {
if (isWebrtcSupported()) {
console.log("I see webRTC !");
$("#status").text("Have webRTC available ");
$("#mute").click(_ => setMute(!mute));
loadProps().then((props) => {
properties = props;
setRole();
})
} else {
console.log("I don't see webRTC !");
$("#status").text("Dont have webRTC available ");
$('#nowebrtc').modal('show');
}
}
});
</script>
</body>
</html>