if("undefined"==typeof jQuery)throw new Error("trackswitchjs's JavaScript requires jQuery. jQuery must be included before trackswitchjs's JavaScript.");(()=>{var t=jQuery.fn.jquery.split(" ")[0].split(".");if(t[0]<2&&t[1]<9||1==t[0]&&9==t[1]&&t[2]<1||4<=t[0])throw new Error("trackswitchjs's JavaScript requires at least jQuery v1.9.1 but less than v4.0.0")})(),(()=>{var n="undefined"!=typeof AudioContext?new AudioContext:"undefined"!=typeof webkitAudioContext?new webkitAudioContext:"undefined"!=typeof mozAudioContext?new mozAudioContext:null,i=(void 0!==document.registerElement&&(document.registerElement("ts-track"),document.registerElement("ts-source")),"trackSwitch"),o={mute:!0,solo:!0,globalsolo:!0,repeat:!1,radiosolo:!1,onlyradiosolo:!1,spacebar:!1,tabview:!1};function e(t,e){this.element=$(t),this.options=$.extend({},o,e),this.options.mute||this.options.solo||(console.error("Cannot disable both solo and mute, reactivating solo"),this.options.solo=!0),this.options.onlyradiosolo&&(this.options.mute=!1,this.options.radiosolo=!0),this._defaults=o,this._name=i,this.numberOfTracks=0,this.longestDuration=0,this.playing=!1,this.repeat=this.options.repeat,this.startTime,this.position=0,this.timerUpdateUI,this.currentlySeeking=!1,this.seekingElement,this.trackProperties=Array(),this.trackSources=Array(),this.trackGainNode=Array(),this.trackBuffer=Array(),this.activeAudioSources=Array(),n&&(this.gainNodeMaster=n.createGain(),this.gainNodeMaster.gain.value=0,this.gainNodeMaster.connect(n.destination)),this.init()}e.prototype.init=function(){var s=this,r=(this.element.addClass("jquery-trackswitch"),0===this.element.find(".main-control").length&&this.element.prepend('
Activate

Infotrackswitch.js - open source multitrack audio player
https://github.com/audiolabs/trackswitch.js

'),0 .seekable)").length&&this.element.find(".main-control .seekwrap").hide(),this.element.find(".seekable:not(.seekable-img-wrap > .seekable)").each(function(){s.originalImage=this.src,$(this).wrap('
'),$(this).after('
')}),this.element.on("touchstart mousedown",".overlay .activate",$.proxy(this.load,this)),this.element.on("touchstart mousedown",".overlay #overlayinfo .info",$.proxy(function(){this.element.find(".overlay .info").hide(),this.element.find(".overlay .text").show()},this)),this.element.one("loaded",$.proxy(this.loaded,this)),this.element.one("errored",$.proxy(this.errored,this)),$(''));if(this.numberOfTracks=this.element.find("ts-track").length,0'+($(this).attr("title")||"Track "+(t+1))+'")}),this.element.append(r),this.options.radiosolo&&(this.trackProperties[0].solo=!0,this.apply_track_properties()),this.updateMainControls(),!n)return this.element.trigger("errored"),this.element.find("#overlaytext").html("Web Audio API is not supported in your browser. Please consider upgrading."),!1}else this.element.trigger("errored")},e.prototype.destroy=function(){this.element.find(".main-control").remove(),this.element.find(".tracks").remove(),this.element.removeData()},e.prototype.sourceFailed=function(t,e,i){void 0!==this.trackSources[t][e+1]?this.prepareRequest(t,e+1):(this.trackProperties[t].error=!0,this.trackStatusChanged())},e.prototype.decodeAudio=function(t,e,i){var o=this,t=t.response;n.decodeAudioData(t,function(t){o.trackGainNode[e]=n.createGain(),o.trackGainNode[e].connect(o.gainNodeMaster),o.trackBuffer[e]=n.createBufferSource(),o.trackBuffer[e].buffer=t,o.trackProperties[e].success=!0,o.trackStatusChanged()},function(t){o.sourceFailed(e,i,"Error Decoding File Type")})},e.prototype.makeRequest=function(t,e){var i=this,o=$(this.trackSources[t][e]).attr("src"),s=new XMLHttpRequest;s.open("GET",o,!0),s.responseType="arraybuffer",s.onreadystatechange=function(){4===s.readyState&&(200===s.status?i.decodeAudio(s,t,e):i.sourceFailed(t,e,"404 - File Not Found"))},s.send()},e.prototype.prepareRequest=function(t,e){void 0!==this.trackSources[t][e]?this.makeRequest(t,e):this.sourceFailed(t,e,"No Source Found")},e.prototype.load=function(t){if(!this.valid_click(t))return!0;t.preventDefault();var o,s,r=this;this.element.find(".overlay span.activate").addClass("fa-spin loading"),0this.longestDuration&&(this.longestDuration=e)}this.element.trigger("loaded")},e.prototype.trackStatusChanged=function(){var e=0,i=0;this.trackProperties.forEach(function(t){e+=t.success||t.error?1:0,i+=t.error?1:0}),e===this.numberOfTracks&&(0===i?this.findLongest():(this.element.trigger("errored"),this.element.find("#overlaytext").html("One or more audio files failed to load.")))},e.prototype.loaded=function(){this.element.find(".overlay").removeClass("loading"),this.element.find(".overlay").hide().remove(),$(this.element).find(".timing .time").html("00:00:00:000"),$(this.element).find(".timing .length").html(this.secondsToHHMMSSmmm(this.longestDuration)),this.apply_track_properties(),this.bindEvents()},e.prototype.errored=function(){this.element.find(".overlay span").removeClass("fa-spin loading"),this.element.addClass("error");var i=this;this.trackProperties.forEach(function(t,e){t.error&&$(i.element).find(".track_list > li:nth-child("+(e+1)+")").addClass("error")}),this.unbindEvents()},e.prototype.unbindEvents=function(){this.element.off("touchstart mousedown",".overlay span"),this.element.off("loaded"),this.element.off("touchstart mousedown",".playpause"),this.element.off("touchstart mousedown",".stop"),this.element.off("touchstart mousedown",".repeat"),this.element.off("mousedown touchstart",".seekwrap"),this.element.off("mousemove touchmove"),this.element.off("mouseup touchend"),this.element.off("touchstart mousedown",".mute"),this.element.off("touchstart mousedown",".solo"),this.options.spacebar&&$(window).unbind("keypress")},e.prototype.bindEvents=function(){var e;this.element.on("touchstart mousedown",".playpause",$.proxy(this.event_playpause,this)),this.element.on("touchstart mousedown",".stop",$.proxy(this.event_stop,this)),this.element.on("touchstart mousedown",".repeat",$.proxy(this.event_repeat,this)),this.element.on("mousedown touchstart",".seekwrap",$.proxy(this.event_seekStart,this)),this.element.on("mousemove touchmove",$.proxy(this.event_seekMove,this)),this.element.on("mouseup touchend",$.proxy(this.event_seekEnd,this)),this.element.on("touchstart mousedown",".mute",$.proxy(this.event_mute,this)),this.element.on("touchstart mousedown",".solo",$.proxy(this.event_solo,this)),this.options.spacebar&&(e=this,$(window).unbind("keypress"),$(window).keypress(function(t){32===t.which&&e.event_playpause(t)}))},e.prototype.valid_click=function(t){return"touchstart"===t.type||"mousedown"===t.type&&1===t.which},e.prototype.secondsToHHMMSSmmm=function(t){var e=(e=parseInt(t/3600)%24)<10?"0"+e:e,i=(i=parseInt(t/60)%60)<10?"0"+i:i,o=t%60,t=(o=(o=o.toString().split(".")[0])<10?"0"+o:o,Math.round(t%1*1e3));return e+":"+i+":"+o+":"+(t<10?"00"+t:t<100?"0"+t:t)},e.prototype.updateMainControls=function(){this.element.find(".playpause").toggleClass("checked",this.playing),this.element.find(".repeat").toggleClass("checked",this.repeat);var t=this.position/this.longestDuration*100;this.element.find(".seekhead").each(function(){$(this).css({left:t+"%"})}),0!==this.longestDuration&&$(this.element).find(".timing .time").html(this.secondsToHHMMSSmmm(this.position))},e.prototype.monitorPosition=function(t){t.position=t.playing&&!t.currentlySeeking?n.currentTime-t.startTime:t.position,t.longestDuration<=t.position&&!t.currentlySeeking&&(t.position=0,t.stopAudio(),t.repeat?t.startAudio(t.position):t.playing=!1),t.updateMainControls()},e.prototype.stopAudio=function(){var t=n.currentTime;this.gainNodeMaster.gain.cancelScheduledValues(t),this.gainNodeMaster.gain.setValueAtTime(1,t),this.gainNodeMaster.gain.linearRampToValueAtTime(0,t+.03);for(var e=0;e