").attr("id","_phono-audio-flash"+(FlashAudio.count++)).addClass("phono_FlashHolder").appendTo("body");flashDiv.css({width:"1px",height:"1px",position:"absolute",top:"50%",left:"50%","margin-top":"-69px","margin-left":"-107px","z-index":"10001",visibility:"visible"});var containerId=$(flashDiv).attr("id");Phono.events.bind(this,{onPermissionBoxShow:function(){$("#"+containerId).css({width:"240px",height:"160px"})},onPermissionBoxHide:function(){$("#"+containerId).css({width:"1px",height:"1px"})}});return containerId};function JavaAudio(phono,config,callback){this.type="java";if(JavaAudio.exists()){this.config=Phono.util.extend({jar:"//s.phono.com/releases/"+Phono.version+"/plugins/audio/phono.audio.jar"},config);Phono.events.bind(this,config);var containerId=this.config.containerId;if(!containerId){this.config.containerId=containerId=_createContainer()}var plugin=this;plugin.$applet=_loadApplet(containerId,this.config.jar,callback,plugin);window.setInterval(function(){var str="Loading...";try{var json=plugin.$applet[0].getJSONStatus();if(json){var statusO=eval("("+json+")");if(!statusO.userTrust){Phono.events.trigger(phono,"error",{reason:"Java Applet not trusted by user - cannot continue"})}else{eps=statusO.endpoints;if(eps.length>0){if((eps[0].sent>50)&&(eps[0].rcvd==0)){Phono.events.trigger(phono,"error",{reason:"Java Applet detected firewall."})}str="share: "+eps[0].uri;str+=" sent "+eps[0].sent;str+=" rcvd "+eps[0].rcvd;str+=" error "+eps[0].error;Phono.log.debug("[JAVA RTP] "+str)}}}else{Phono.events.trigger(phono,"error",{reason:"Java applet did not load."});Phono.log.debug("[JAVA Load errror] no status returned.")}}catch(e){Phono.events.trigger(phono,"error",{reason:"Can not communicate with Java Applet - perhaps it did not load."});Phono.log.debug("[JAVA Load error] "+e)}},25000)}else{Phono.events.trigger(phono,"error",{reason:"Java not available in this browser."})}}JavaAudio.exists=function(){return(navigator.javaEnabled())};JavaAudio.count=0;JavaAudio.prototype.play=function(transport,autoPlay){var url=transport.uri;var applet=this.$applet[0];var player;var luri=url;var uri=Phono.util.parseUri(url);var location=Phono.util.parseUri(document.location);if(uri.protocol=="rtp"){return null}if(url.indexOf("//")==0){luri=location.protocol+":"+url}else{if(uri.protocol.length<2){luri=location.protocol+"://"+location.authority+location.directoryPath+url}}if(autoPlay===undefined){autoPlay=false}player=applet.play(luri,autoPlay);return{url:function(){return player.getUrl()},start:function(){player.start()},stop:function(){player.stop()},volume:function(){if(arguments.length===0){return player.volume()}else{player.volume(value)}}}};JavaAudio.prototype.share=function(transport,autoPlay,codec,srtpPropsl,srtpPropsr){var url=transport.uri;var applet=this.$applet[0];Phono.log.debug("[JAVA share codec ] "+codec.p.pt+" id = "+codec.id);var acodec=applet.mkCodec(codec.p,codec.id);var share;var isSecure=false;if(srtpPropsl!=undefined&&srtpPropsr!=undefined){share=applet.share(url,acodec,autoPlay,srtpPropsl,srtpPropsr);isSecure=true}else{share=applet.share(url,acodec,autoPlay)}return{url:function(){return share.getUrl()},codec:function(){var codec=share.getCodec();return{id:codec.getId(),name:codec.getName(),rate:codec.getRate()}},start:function(){share.start()},stop:function(){share.stop()},digit:function(value,duration,audible){share.digit(value,duration,audible)},gain:function(value){if(arguments.length===0){return share.gain()}else{share.gain(value)}},mute:function(value){if(arguments.length===0){return share.mute()}else{share.mute(value)}},suppress:function(value){if(arguments.length===0){return share.doES()}else{share.doES(value)}},energy:function(){var en=share.energy();return{mic:Math.floor(Math.max((Math.LOG2E*Math.log(en[0])-4),0)),spk:Math.floor(Math.max((Math.LOG2E*Math.log(en[1])-4),0))}},secure:function(){return isSecure}}};JavaAudio.prototype.permission=function(){return true};JavaAudio.prototype.transport=function(){var applet=this.$applet[0];var endpoint=applet.allocateEndpoint();return{name:"urn:xmpp:jingle:transports:raw-udp:1",description:"urn:xmpp:jingle:apps:rtp:1",supportsSRTP:true,buildTransport:function(direction,j,callback){var uri=Phono.util.parseUri(endpoint);j.c("transport",{xmlns:"urn:xmpp:jingle:transports:raw-udp:1"}).c("candidate",{ip:uri.domain,port:uri.port,generation:"1"});callback()},processTransport:function(t){var fullUri;t.find("candidate").each(function(){fullUri=endpoint+":"+$(this).attr("ip")+":"+$(this).attr("port")});return{input:{uri:fullUri},output:{uri:fullUri}}}}};String.prototype.startsWith=function(str){return(this.match("^"+str)==str)};JavaAudio.prototype.codecs=function(){var result=new Array();var applet=this.$applet[0];var codecs=applet.codecs();for(l=0;l
0){result.push(mixers[l].name)}}return result};_createContainer=function(){var appletDiv=$("").attr("id","_phono-appletHolder"+(JavaAudio.count++)).addClass("phono_AppletHolder").appendTo("body");appletDiv.css({width:"1px",height:"1px",position:"absolute",top:"50%",left:"50%","margin-top":"-69px","margin-left":"-107px","z-index":"10001",visibility:"visible"});var containerId=$(appletDiv).attr("id");return containerId};_loadApplet=function(containerId,jar,callback,plugin){var id="_phonoAudio"+(JavaAudio.count++);var callbackName=id+"Callback";window[callbackName]=function(devJson){plugin.audioDeviceList=devJson;t=window.setTimeout(function(){callback(plugin)},10)};var applet=$("