console.log("audioController.js");var tettool_audioController={init:function init(b,a){console.log("tet.tool",a.attr("id"),a.attr("itemtitle"))},init_audio:function(){var h=$(this);if(h.next().hasClass("audioPlayer")){return}this.removeAttribute("controls");var b=h.closest(".tetitem");b.attr("ignoreDblClick","ignoreDblClick");var n=h;var r=$('<div class="audioPlayer">    <div class="progressBar">    	<div class="progressBarGrabber">        </div>    </div>    <div class="ppBtn"></div><!--play/pause Button-->    <div class="volume">    	<div class="speaker">        </div>        <div class="slider">        	<div class="visibleSlider">            	<div class="vsg"></div>            </div>        </div>    </div> 	<div class="timeCode">0</div><!--fullScreen Button--></div>').insertAfter(h);var A=this;var a=r.find(".progressBar");var c=r.find(".progressBarGrabber");var s=r.find(".ppBtn");var k=r.find(".timeCode");var x=r.find(".slider");var e=r.find(".vsg");var v=r.find(".speaker");var g=false;var y=a.parents(".tetitem_inner").get().reduce(function(B,C){return B*(get_css_transform(C).scale||1)},1);p();i();n.on("timeupdate",u);a.on("mousedown.ap touchstart.ap",z);x.on("mousedown.apv touchstart.apv",m);s.on("click",l);n.on("play pause",j);n.on("volumechange",i);v.on("click",q);A.addEventListener("loadedmetadata",function(){k.html(d(A.duration));k.attr("duration",d(A.duration));k.attr("durationSec",A.duration)});function w(B){return B<0?0:B>1?1:B}function z(C){var B=A.paused;g=true;A.pause();C.preventDefault();C=(C.originalEvent.touches)?C.originalEvent.touches[0]:C;var E=C.clientX-$(this).offset().left;var D=E/$(this).width()/y;t(D);$(document).on("mousemove.ap touchmove.ap",function(F){F.preventDefault();F=(F.originalEvent.touches)?F.originalEvent.touches[0]:F;var H=F.clientX-a.offset().left;var G=H/a.width()/y;t(G)});$(document).one("mouseup.ap touchend.ap",function(){a.off("mousemove.ap touchmove.ap");$(document).off("mousemove.ap touchmove.ap");if(!B){A.play()}g=false})}function u(B){o(this.currentTime/this.duration,c);k.html(d(this.currentTime))}function m(B){B.preventDefault();B=(B.originalEvent.touches)?B.originalEvent.touches[0]:B;var D=B.clientX-$(this).offset().left;var C=D/$(this).width()/y;if(C>0){A.muted=false}f(C);$(document).on("mousemove.apv touchmove.apv",function(E){E.preventDefault();E=(E.originalEvent.touches)?E.originalEvent.touches[0]:E;var G=E.clientX-x.offset().left;var F=G/x.width()/y;f(F)});$(document).one("mouseup.apv touchend.apv",function(){a.off("mousemove.apv touchmove.apv");$(document).off("mousemove.apv touchmove.apv")})}function o(D,B){if(isNaN(D)||!isFinite(D)){return}var C=w(D);B.css("width",100*C+"%")}function t(C){if(isNaN(C)||!isFinite(C)){return}var B=w(C);A.currentTime=A.duration*B}function f(C){if(isNaN(C)||!isFinite(C)){console.log("invalid volume");return}var B=w(C);A.volume=B}function l(){if(A.paused){A.play()}else{A.pause()}}function j(B){if(g){return}if(B.type!=="play"){s.removeClass("tetvideoplayer_pause").addClass("tetvideoplayer_play")}else{s.removeClass("tetvideoplayer_play").addClass("tetvideoplayer_pause")}}function i(C){var B=A.muted?0:A.volume;o(B,e);if(B==0){v.css("background-position","0 5px")}else{if(B<1/3){v.css("background-position","0 -35px")}else{if(B<2/3){v.css("background-position","0 -75px")}else{v.css("background-position","0 -115px")}}}}function q(){if(A.muted){A.muted=false}else{A.muted=true}}function d(H){if(isNaN(H)||!isFinite(H)){console.log("hms() audio error: invalid time");return"0:00"}var E=Math.floor(H/3600);H-=3600*E;var B=Math.floor(H/60);H-=60*B;var D=Math.floor(H);var G=String(E);var C=String(B);var F=String(D);var I="";if(E>0){I=G+":"}if(B>=10||E==0){I=I+C+":"}else{I=I+"0"+C+":"}if(D>=10){I=I+F}else{I=I+"0"+F}return I}function p(){var B=new Audio();B.volume=0.5;if(B.volume==1){r.find(".volume").css({opacity:0.2,"pointer-events":"none"})}}}};