!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e:t.lunar=e()}(this,function(){"use strict";var t={hasClass:function(t,e){return new RegExp("(\\s|^)"+e+"(\\s|$)").test(t.attr("class"))},addClass:function(e,s){!t.hasClass(e,s)&&e.attr("class",(e.getAttribute("class")?e.getAttribute("class")+" ":"")+s)},removeClass:function(e,s){var a=e.attr("class").replace(new RegExp("(\\s|^)"+s+"(\\s|$)","g"),"$2");t.hasClass(e,s)&&e.attr("class",a)},toggleClass:function(e,s){t[t.hasClass(e,s)?"removeClass":"addClass"](e,s)},className:function(t,e){t.attr("class",e),console.log("className",t)}};return t}),function(t){var e={cursorPoint:function(t,s){e.settings.pt.x=t.clientX,e.settings.pt.y=t.clientY;var a=s.find("svg").attr("id");return a=document.getElementById(a),e.settings.pt.matrixTransform(a.getScreenCTM().inverse())},angle:function(t,e){var s=e-50,a=t-50,r=Math.atan2(s,a);return r*=180/Math.PI,(r+=90)<0&&(r=360+r),r},setGraphValue:function(s,a,r){var o=r.find(e.settings.audioObj),i=e.settings.pc,n=i-parseFloat(a/o[0].duration*i,10);t(s).css("strokeDashoffset",n),0===a&&(t(s).addClass(s,"done"),s===t(e.settings.progress)&&t(s).attr("class","ended"))},reportPosition:function(t,s){var a=t.find(e.settings.progress);t.find(e.settings.audioObj);e.setGraphValue(a,s.currentTime,t)},stopAllSounds:function(){document.addEventListener("play",function(e){for(var s=document.getElementsByTagName("audio"),a=0,r=s.length;a','','','','',"",'','','','',"",'','',"",'','',"",""];a=a.join(" "),t.each(this,function(e,s){var r=t(this).find("audio");r.attr("id","audio"+e),a=(a=(a=a.replace('width="34"','width="'+r.data("size")+'"')).replace('height="34"','height="'+r.data("size")+'"')).replace('id="playable"','id="playable'+e+'"'),t(this).append(a)});var r=t(this).find("svg").attr("id");r=document.getElementById(r),e.defaults={this:this,thisSelector:this.selector.toString(),playObj:"playable",progress:".progress-bar",precache:".precache-bar",audioObj:"audio",controlsObj:".controls",pt:r.createSVGPoint(),pc:298.1371428256714},lunar={},e.settings=t.extend({},e.defaults,s),t(e.settings.controlsObj).on("click",function(s){var a=t(s.currentTarget).closest(t(e.settings.thisSelector)),r={el:a,activeAudio:a.find(e.settings.audioObj),playObj:a.find("[data-play]"),precache:a.find(e.settings.precache)};switch(r.class=r.playObj.attr("class"),r.class.replace("playable","").trim()){case"not-started":e.stopAllSounds(),r.activeAudio[0].play();var o=document.getElementById(r.activeAudio.attr("id"));o.addEventListener("timeupdate",function(t){e.reportPosition(a,o)}),r.playObj.attr("class","playing");break;case"playing":r.playObj.attr("class","playable paused"),r.activeAudio[0].pause(),t(o).off("timeupdate");break;case"paused":r.playObj.attr("class","playable playing"),r.activeAudio[0].play();break;case"ended":r.playObj.attr("class","not-started playable"),r.activeAudio.off("timeupdate",e.reportPosition)}}),t(e.defaults.audioObj).on("progress",function(s){if(this.buffered.length>0){var a=this.buffered.end(this.buffered.length-1),r=t(s.currentTarget).parent().find(e.settings.precache),o=t(this).closest(t(e.settings.thisSelector));e.setGraphValue(r,a,o)}})}};t.fn.mediaPlayer=function(s){return e[s]?e[s].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof s&&s?void t.error("Method "+s+" does not exist on jQuery.mediaPlayer"):e.init.apply(this,arguments)}}(jQuery); $(document).ready(function () { $('.mediPlayer').mediaPlayer(); });