Advertisement
BLUSHIF

Untitled

Aug 2nd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. var webrtc=new SimpleWebRTC({remoteVideosEl:'remotesVideos',localVideoEl:'localVideo',autoRequestMedia:true,detectSpeakingEvents:true,autoAdjustMic:false,url:'https://www.hokucode.com/',socketio:{path:"/signal/socket.io"},enableDataChannels:true,media:{video:false,audio:true},debug:false});var thisNumRand;if(location.protocol=="http:"){alert("Please use https://www. on our page, otherwise RTC will not function.")}function showVolume(el,volume){if(!el){return}if(volume<-45){volume=-45}if(volume>-20){volume=-20}el.value=volume}function track(name,info){if(webrtc&&webrtc.connection){webrtc.connection.emit('metrics',name,info||{})}}webrtc.on('createdPeer',function(peer){var pyd=peer.id.substring(0,6);for(var i=0;i<6;i+=1){var strout=0;var alphabet=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0","-"];var letter=pyd[i];var letterPosition=alphabet.indexOf(letter)+1;strout=strout+letterPosition;if(i==0){thisNumRand=strout*26291}}var remotes=document.getElementById('remotes');if(!remotes){return}var container=document.createElement('div');container.className='peerContainer';container.id='container_'+webrtc.getDomId(peer);var tri=document.createElement('tr');var th=document.createElement('th');var name=document.createElement('h3');name.style.color="#"+thisNumRand;txn=document.createTextNode("Anon "+thisNumRand);name.appendChild(txn);th.appendChild(name);var thi=document.createElement('th');var thii=document.createElement('th');var img=document.createElement('img');img.src="speaker.png";img.height=50;img.width=50;var mute=document.createElement('a');var vol=document.createElement('meter');vol.id='volume_'+peer.id;vol.className='volume';vol.min=-45;vol.max=-20;vol.low=-40;vol.high=-25;thi.appendChild(mute);mute.appendChild(img);thii.appendChild(vol);tri.appendChild(thi);tri.appendChild(th);tri.appendChild(thii);container.appendChild(tri);remotes.appendChild(container);var bv=true;mute.onclick=function(){var cli="#"+webrtc.getDomId(peer);bv=!bv;var bnt=peer.id;if(bv==false){$(cli).prop('muted',true);img.src='muted.png';webrtc.sendDirectlyToAll('channelMessage','chat',{messageBody:"m",cid:bnt})}else{$(cli).prop('muted',false);img.src='speaker.png';webrtc.sendDirectlyToAll('channelMessage','chat',{messageBody:"u",cid:bnt})}};if(peer&&peer.pc){peer.firsttime=true;peer.pc.on('iceConnectionStateChange',function(event){var state=peer.pc.iceConnectionState;container.className='peerContainer p2p'+state.substr(0,1).toUpperCase()+state.substr(1);switch(state){case 'connected':case 'completed':mute.style.visibility='visible';if(peer.firsttime){peer.firsttime=false;track('iceSuccess',{session:peer.sid,peerprefix:peer.browserPrefix,prefix:webrtc.capabilities.prefix,version:webrtc.capabilities.browserVersion})}break;case 'closed':container.remove();break}})}remotes.appendChild(container)});webrtc.on('volumeChange',function(volume,threshold){showVolume(document.getElementById('localVolume'),volume)});webrtc.on('remoteVolumeChange',function(peer,volume){showVolume(document.getElementById('volume_'+peer.id),volume)});var totalSeconds=0;setInterval(setTime,1000);function setTime(){totalSeconds+=1;if(totalSeconds>300){webrtc.leaveRoom();rmc("ind")}}var px=true;function mute(){px=!px;if(px==true){webrtc.unmute();$("#urimg").attr("src","speaker.png")}else{webrtc.mute();$("#urimg").attr("src","muted.png")}}var rba;window.addEventListener('load',function(){rmc("ind")},false);function rmc(rme){if(rme!="ind"){webrtc.leaveRoom();webrtc.joinRoom(rme);rba=rme;$('#bdrp').text(rme);vxt("v")}else{webrtc.stopLocalVideo();webrtc.leaveRoom();$('#bdrp').text("");vxt("i")}}function tsh(){$('#tos').css('display','inline')}function vxt(val){if(val=="i"){$('#indiv').css('display','none');$('#cdiv').css('display','inline')}else{$('#indiv').css('display','inline');$('#cdiv').css('display','none')}}var pmu=0;webrtc.on('channelMessage',function(peer,label,data){var ns=(document.getElementsByClassName("p2pCompleted").length)+(document.getElementsByClassName("p2pConnected").length);if(data.type==='chat'){if(data.payload.cid==webrtc.connection.getSessionid()){if(data.payload.messageBody=="m"){pmu=pmu+1}else if(data.payload.messageBody=="u"&&pmu>0){pmu=pmu-1}if(pmu==ns&&ns>1){webrtc.stopLocalVideo();webrtc.leaveRoom();rmc("ind")}}}});//All code here excluding jquery and the swrtc library is the property of JST.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement