/* playemjs 1.3.3, commit: 7ee62713169a0ee48e1b63ae1999786bd461b22a */ var DEFAULT_PLAY_TIMEOUT=1e4;window.$=window.$||function(){return window.$};if(undefined==window.console){window.console={log:function(){}}}function Loader(){var FINAL_STATES={loaded:true,complete:true,4:true};var head=document.getElementsByTagName("head")[0];var pending={};var counter=0;return{loadJSON:function(src,cb){var xdr=new window.XMLHttpRequest;xdr.onload=function(){var data=xdr.responseText;try{data=JSON.parse(data)}catch(e){}cb(data)};xdr.open("GET",src,true);xdr.send()},includeJS:function(src,cb){var inc,nt;if(pending[src]){if(cb){nt=setInterval((function(){if(pending[src]){return console.log("still loading",src,"...")}clearInterval(nt);cb()}),50)}return}pending[src]=true;inc=document.createElement("script");inc.onload=function(){if(!pending[src]){return}delete pending[src];cb&&setTimeout(cb,1);delete inc.onload};inc.onerror=function(e){e.preventDefault();inc.onload(e)};inc.onreadystatechange=function(){if(!inc.readyState||FINAL_STATES[inc.readyState]){inc.onload()}};try{inc.src=src;head.appendChild(inc)}catch(e){console.error("Error while including",src,e);cb(e)}},loadJSONP:function(src,cb){var callbackFct="__loadjsonp__"+counter++;window[callbackFct]=function(){cb.apply(window,arguments);delete window[callbackFct]};this.includeJS(src+(src.indexOf("?")==-1?"?":"&")+"callback="+callbackFct,(function(){setTimeout(window[callbackFct],10)}))}}}window.loader=new Loader;function EventEmitter(){this._eventListeners={}}EventEmitter.prototype.on=function(eventName,handler){this._eventListeners[eventName]=(this._eventListeners[eventName]||[]).concat(handler)};EventEmitter.prototype.emit=function(eventName){var i;var args=Array.prototype.slice.call(arguments,1);var listeners=this._eventListeners[eventName];for(i in listeners){listeners[i].apply(null,args)}};function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}function Playem(playemPrefs){function Playem(playemPrefs){EventEmitter.call(this);playemPrefs=playemPrefs||{};playemPrefs.loop=playemPrefs.hasOwnProperty("loop")?playemPrefs.loop:true;playemPrefs.playTimeoutMs=playemPrefs.playTimeoutMs||DEFAULT_PLAY_TIMEOUT;var players=[];var i;var exportedMethods;var currentTrack=null;var trackList=[];var whenReady=null;var playersToLoad=0;var progress=null;var that=this;var playTimeout=null;var volume=1;this.setPref=function(key,val){playemPrefs[key]=val};function doWhenReady(player,fct){var interval=null;function poll(){if(player.isReady&&interval){clearInterval(interval);fct()}else{console.warn("PLAYEM waiting for",player.label,"...")}}if(player.isReady){setTimeout(fct)}else{interval=setInterval(poll,1e3)}}function addTrack(metadata,url){var track={index:trackList.length,metadata:metadata||{}};if(url){track.url=url}trackList.push(track);return track}function addTrackById(id,player,metadata){if(id){var track=addTrack(metadata);track.trackId=id;track.player=player;track.playerName=player.label.replace(/ /g,"_");return track}else{throw new Error("no id provided")}}function searchTracks(query,handleResult){var expected=0;var i;var currentPlayer;for(i=0;i",e)}}function playTrack(track){stopTrack();currentTrack=track;delete currentTrack.trackPosition;delete currentTrack.trackDuration;that.emit("onTrackChange",track);if(!track.player){return that.emit("onError",{code:"unrecognized_track",source:"Playem",track:track})}doWhenReady(track.player,(function(){callPlayerFct("play",track.trackId);setVolume(volume);if(currentTrack.index==trackList.length-1){that.emit("loadMore")}setPlayTimeout((function(){console.warn("PLAYEM TIMEOUT");that.emit("onError",{code:"timeout",source:"Playem"})}))}))}function setPlayTimeout(handler){if(playTimeout){clearTimeout(playTimeout)}playTimeout=!handler?null:setTimeout(handler,playemPrefs.playTimeoutMs)}function callPlayerFct(fctName,param){try{return currentTrack.player[fctName](param)}catch(e){console.warn("Player call error",fctName,e,e.stack)}}function createEventHandlers(playemFunctions){var eventHandlers={onApiReady:function(player){if(whenReady&&player==whenReady.player){whenReady.fct()}if(--playersToLoad==0){that.emit("onReady")}},onEmbedReady:function(player){setVolume(volume)},onBuffering:function(player){setTimeout((function(){setPlayTimeout();that.emit("onBuffering")}))},onPlaying:function(player){setVolume(volume);setTimeout((function(){that.emit("onPlay")}),1);if(player.trackInfo&&player.trackInfo.duration){eventHandlers.onTrackInfo({position:player.trackInfo.position||0,duration:player.trackInfo.duration})}if(progress){clearInterval(progress)}if(player.getTrackPosition){progress=setInterval((function(){player.getTrackPosition((function(trackPos){eventHandlers.onTrackInfo({position:trackPos,duration:player.trackInfo.duration||currentTrack.trackDuration})}))}),1e3)}},onTrackInfo:function(trackInfo){if(currentTrack&&trackInfo){if(trackInfo.duration){currentTrack.trackDuration=trackInfo.duration;setPlayTimeout()}if(trackInfo.position){currentTrack.trackPosition=trackInfo.position}}that.emit("onTrackInfo",currentTrack)},onPaused:function(player){setPlayTimeout();if(progress){clearInterval(progress)}progress=null},onEnded:function(player){stopTrack();that.emit("onEnd");playemFunctions.next()},onError:function(player,error){console.error(player.label+" error:",((error||{}).exception||error||{}).stack||error);setPlayTimeout();that.emit("onError",error)}};["onEmbedReady","onBuffering","onPlaying","onPaused","onEnded","onError"].map((function(evt){var fct=eventHandlers[evt];eventHandlers[evt]=function(player,x){if(currentTrack&&player==currentTrack.player){return fct(player,x)}}}));return eventHandlers}exportedMethods={addPlayer:function(PlayerClass,vars){playersToLoad++;var player=new PlayerClass(createEventHandlers(this,vars),vars);players.push(player);return player},getPlayers:function(){return players},getQueue:function(){return trackList},clearQueue:function(){trackList=[]},addTrackByUrl:function(url,metadata){var p,player,eid;for(p=0;p0||!ignoreEnded)that.safeClientCall(EVENT_MAP[newState],that);else--ignoreEnded};window.onDailymotionError=function(error){console.log("DM error",error);that.safeClientCall("onError",that,{source:"DailymotionPlayer",data:error})};window.onDailymotionAdStart=function(){that.safeClientCall("onBuffering",that)};window.onDailymotionPlayerReady=function(playerId){that.element=document.getElementById(playerId);that.element.addEventListener("onStateChange","onDailymotionStateChange");that.element.addEventListener("onError","onDailymotionError");that.element.addEventListener("onLinearAdStart","onDailymotionAdStart")};that.isReady=true;that.safeClientCall("onApiReady",that)}Player.prototype.safeCall=function(fctName,p1,p2){var args=Array.apply(null,arguments).slice(1),fct=(this.element||{})[fctName];return fct&&fct.apply(this.element,args)};Player.prototype.safeClientCall=function(fctName,p1,p2){try{return this.eventHandlers[fctName]&&this.eventHandlers[fctName](p1,p2)}catch(e){console.error("DM safeclientcall error",e.stack)}};Player.prototype.embed=function(vars){this.embedVars=vars=vars||{};this.embedVars.playerId=this.embedVars.playerId||"dmplayer";this.trackInfo={};this.element=document.createElement("object");this.element.id=this.embedVars.playerId;this.embedVars.playerContainer.appendChild(this.element);var paramsQS,paramsHTML,embedAttrs,params={allowScriptAccess:"always"},atts={id:this.embedVars.playerId},swfParams={info:0,logo:0,related:0,autoplay:1,enableApi:1,showinfo:0,hideInfos:1,chromeless:1,withLoading:0,playerapiid:this.embedVars.playerId};paramsQS=Object.keys(swfParams).map((function(k){return k+"="+encodeURIComponent(swfParams[k])})).join("&");paramsHTML=Object.keys(params).map((function(k){return''})).join();embedAttrs={id:this.embedVars.playerId,width:this.embedVars.width||"200",height:this.embedVars.height||"200",type:"application/x-shockwave-flash",data:window.location.protocol+"//www.dailymotion.com/swf/"+this.embedVars.videoId+"?"+paramsQS,innerHTML:paramsHTML};$(this.element).attr(embedAttrs);$(this.element).show();this.safeClientCall("onEmbedReady")};Player.prototype.getEid=function(url){return regex.test(url)&&RegExp.lastParen};function fetchMetadata(id,cb){var url=encodeURIComponent("http://www.dailymotion.com/embed/video/"+id),callbackFct="dmCallback_"+id.replace(/[-\/]/g,"__");window[callbackFct]=function(data){cb(!data||!data.title?null:{id:id,title:data.title,img:data.thumbnail_url})};loader.includeJS("//www.dailymotion.com/services/oembed?format=json&url="+url+"&callback="+callbackFct)}Player.prototype.fetchMetadata=function(url,cb){var id=this.getEid(url);if(!id)return cb();fetchMetadata(id,cb)};Player.prototype.play=function(id){if(!this.currentId||this.currentId!=id){this.embedVars.videoId=id;this.embed(this.embedVars)}};Player.prototype.pause=function(vol){this.safeCall("pauseVideo")};Player.prototype.resume=function(vol){this.safeCall("playVideo")};Player.prototype.stop=function(vol){++ignoreEnded;this.safeCall("clearVideo");if((this.element||{}).parentNode)this.element.parentNode.removeChild(this.element)};Player.prototype.getTrackPosition=function(callback){this.trackInfo.duration=this.safeCall("getDuration");callback&&callback(this.safeCall("getCurrentTime"))};Player.prototype.setTrackPosition=function(pos){this.safeCall("seekTo",pos)};Player.prototype.setVolume=function(vol){this.safeCall("setVolume",vol*100)};DailymotionPlayer.prototype=Player.prototype;DailymotionPlayer.super_=Player})();try{module.exports=DailymotionPlayer}catch(e){}window.showMessage=window.showMessage||function(msg){console.warn("[showMessage]",msg)};window.$=window.$||function(){return window.$};$.getScript=$.getScript||function(js,cb){loader.includeJS(js,cb)};$.append=$.append||function(html){document.write(html)};function DeezerPlayer(){return DeezerPlayer.super_.apply(this,arguments)}(function(){var SDK_URL="https://cdns-files.deezer.com/js/min/dz.js",IS_LOGGED=false,URL_REG=/(deezer\.com\/(?:fr\/)?track|\/dz)\/(\d+)/,EVENT_MAP={player_play:"onPlaying",player_paused:"onPaused",track_end:"onEnded"};function Player(eventHandlers){var self=this;this.label="Deezer";this.eventHandlers=eventHandlers||{};this.currentTrack={position:0,duration:0};loadSDK((function(){self.isReady=true;try{eventHandlers.onApiReady(self)}catch(e){}}))}Player.prototype.isLogged=function(){return IS_LOGGED};Player.prototype.getEid=function(url){return URL_REG.test(url)&&RegExp.lastParen};function fetchMetadata(id,cb){var callbackFct="dzCallback_"+id.replace(/[-\/]/g,"__");window[callbackFct]=function(data){delete window[callbackFct];cb(!data||!data.album?null:{id:id,title:data.artist.name+" - "+data.title,img:data.album.cover})};loader.includeJS("//api.deezer.com/track/"+id+"?output=jsonp&callback="+callbackFct)}Player.prototype.fetchMetadata=function(url,cb){var id=this.getEid(url);if(!id)return cb();fetchMetadata(id,cb)};Player.prototype.play=function(id){var self=this;this.init((function(){if(IS_LOGGED){DZ.player.playTracks([id],0)}else{DZ.api("/track/"+id,(function(data){showMessage("This is a 30 secs preview. "+''+"Connect to Deezer to listen to the full track.");self.sound=createSound(self,data.preview)}))}}))};Player.prototype.pause=function(){if(this.sound){this.sound.pause()}else{DZ.player.pause()}};Player.prototype.stop=function(){console.log("DEEZER STOP");if(!this.isReady)return;if(this.sound){this.sound.stop();this.sound.destruct();this.sound=null}else{document.getElementById("dz-root").innerHTML=""}};Player.prototype.resume=function(){if(this.sound){this.sound.resume()}else{DZ.player.play()}};Player.prototype.setTrackPosition=function(pos){if(this.sound)this.sound.setPosition(Math.round(pos*1e3));else DZ.player.seek(Math.round(100*pos/this.currentTrack.duration))};Player.prototype.setVolume=function(vol){if(this.sound)this.sound.setVolume(Math.round(vol*100));else DZ.player.setVolume(Math.round(vol*100))};function loadSDK(cb){var dz;if(window.DZ)return cb();if(!document.getElementById("dz-root")){dz=document.createElement("div");dz.id="dz-root";document.getElementsByTagName("body")[0].appendChild(dz)}loader.includeJS(SDK_URL,cb)}Player.prototype.init=function(onload){var self=this;DZ.init({appId:DEEZER_APP_ID,channelUrl:DEEZER_CHANNEL_URL,player:{onload:function(){if(window.location.protocol==="https:")DZ.override_https();DZ.getLoginStatus((function(response){IS_LOGGED=response.userID;hookHandlers(self);onload.call(null,arguments)}))}}})};function hookHandlers(self){DZ.Event.subscribe("player_position",(function(eventObject){var onTrackInfoHandler=self.eventHandlers.onTrackInfo,onEndedHandler=self.eventHandlers.onEnded,position=eventObject[0],duration=eventObject[1];if(onTrackInfoHandler){self.currentTrack={position:position,duration:duration};onTrackInfoHandler(self.currentTrack)}if(duration-position<=1.5&&onEndedHandler)onEndedHandler(self)}));function createHandler(e){return function(){var handler=self.eventHandlers[EVENT_MAP[e]];handler&&handler(self)}}for(var e in EVENT_MAP)DZ.Event.suscribe(e,createHandler(e))}function createSound(self,url){return soundManager.createSound({id:"deezerSound"+Date.now(),url:url,autoLoad:true,autoPlay:true,whileplaying:function(){if(self.sound)self.currentTrack={position:self.sound.position/1e3,duration:self.sound.duration/1e3};if(self.eventHandlers.onTrackInfo)self.eventHandlers.onTrackInfo(self.currentTrack)},onplay:function(){if(self.eventHandlers.onPlaying)self.eventHandlers.onPlaying(self)},onresume:function(){if(self.eventHandlers.onPlaying)self.eventHandlers.onPlaying(self)},onfinish:function(){if(self.eventHandlers.onEnded)self.eventHandlers.onEnded(self)}})}DeezerPlayer.login=function(){DZ.login((function(response){if(response.userID){IS_LOGGED=true;showMessage("Login successful. Your Deezer tracks will be full length from now on!")}else{showMessage("Deezer login unsuccesful.",true)}}),{perms:"email"})};DeezerPlayer.prototype=Player.prototype;DeezerPlayer.super_=Player})();try{module.exports=DeezerPlayer}catch(e){}function JamendoPlayer(){return JamendoPlayer.super_.apply(this,arguments)}(function(){var EVENT_MAP={onplay:"onPlaying",onresume:"onPlaying",onpause:"onPaused",onstop:"onPaused",onfinish:"onEnded"};function Player(eventHandlers,embedVars){this.label="Jamendo track";this.eventHandlers=eventHandlers||{};this.embedVars=embedVars||{};this.element=null;this.widget=null;this.isReady=false;this.trackInfo={};var i,loading,that=this;this.soundOptions={id:null,url:null,autoLoad:true,autoPlay:true,ontimeout:function(e){that.eventHandlers.onError&&that.eventHandlers.onError(that,{code:"timeout",source:"JamendoPlayer"})}};for(i in EVENT_MAP)(function(i){that.soundOptions[i]=function(){var handler=eventHandlers[EVENT_MAP[i]];handler&&handler(that)}})(i);loading=setInterval((function(){try{if(window["soundManager"]){clearInterval(loading);that.isReady=true;eventHandlers.onApiReady&&eventHandlers.onApiReady(that)}}catch(e){that.eventHandlers.onError&&that.eventHandlers.onError(that,{source:"JamendoFilePlayer",exception:e})}}),200)}Player.prototype.getEid=function(url){return/jamendo.com\/.*track\/(\d+)/.test(url)||/\/ja\/(\d+)/.test(url)?RegExp.$1:null};function fetchMetadata(url,id,cb){var callbackFct="jaCallback_"+id.replace(/[-\/]/g,"__");window[callbackFct]=function(data){delete window[callbackFct];cb(!data||!data.results||!data.results.length?null:{id:data.results[0].id,img:data.results[0].album_image,title:data.results[0].artist_name+" - "+data.results[0].name})};loader.includeJS("//api.jamendo.com/v3.0/tracks?client_id="+JAMENDO_CLIENT_ID+"&id="+id+"&callback="+callbackFct)}Player.prototype.fetchMetadata=function(url,cb){var id=this.getEid(url);if(!id)return cb();fetchMetadata(url,id,cb)};Player.prototype.getTrackInfo=function(callback){var that=this,i=setInterval((function(){if(that.widget&&that.widget.duration){clearInterval(i);callback(that.trackInfo={duration:that.widget.duration/1e3,position:that.widget.position/1e3})}}),500)};Player.prototype.getTrackPosition=function(callback){var that=this;this.getTrackInfo((function(){callback(that.trackInfo.position);that.eventHandlers.onTrackInfo&&that.eventHandlers.onTrackInfo(that.trackInfo)}))};Player.prototype.setTrackPosition=function(pos){this.widget&&this.widget.setPosition(Math.floor(Math.min(this.widget.duration,pos*1e3)-2e3))};Player.prototype.embed=function(vars){if(!vars||!vars.trackId)return;this.embedVars=vars=vars||{};this.soundOptions.id=vars.playerId=vars.playerId||"mp3Player"+(new Date).getTime();this.soundOptions.url="//api.jamendo.com/v3.0/tracks/file?client_id="+JAMENDO_CLIENT_ID+"&action=stream&audioformat=mp32&id="+vars.trackId;this.trackInfo={};if(this.widget){try{this.pause()}catch(err){console.warn("[playemjs] jamendo.embed() failed to pause()",err)}this.widget=null;delete this.widget}this.widget=soundManager.createSound(this.soundOptions);this.eventHandlers.onEmbedReady&&this.eventHandlers.onEmbedReady(this);this.eventHandlers.onTrackInfo&&this.getTrackInfo(this.eventHandlers.onTrackInfo);this.play()};Player.prototype.play=function(id){this.isReady&&this.embed({trackId:id})};Player.prototype.resume=function(){this.isReady&&this.widget&&this.widget.resume()};Player.prototype.pause=function(){try{this.isReady&&this.widget&&this.widget.pause()}catch(e){console.error("jamendo error:",e,e.stack)}};Player.prototype.stop=function(){this.widget&&this.widget.stop()};Player.prototype.setVolume=function(vol){if(this.widget&&this.widget.setVolume&&this.soundOptions)soundManager.setVolume(this.soundOptions.id,100*vol)};JamendoPlayer.prototype=Player.prototype;JamendoPlayer.super_=Player})();try{module.exports=JamendoPlayer}catch(e){}function SoundCloudPlayer(){return SoundCloudPlayer.super_.apply(this,arguments)}(function(){function Player(eventHandlers,embedVars){this.label="SoundCloud";this.eventHandlers=eventHandlers||{};this.embedVars=embedVars||{};this.element=null;this.widget=null;this.isReady=false;this.trackInfo={};this.soundOptions={};var that=this;this.callHandler=function(name,params){try{eventHandlers[name]&&eventHandlers[name](params)}catch(e){console.error("SC error:",e,e.stack)}};function init(){that.isReady=true;that.callHandler("onApiReady",that)}if(window.SC)init();else{loader.includeJS("https://w.soundcloud.com/player/api.js",(function(){init()}))}}Player.prototype.safeCall=function(fctName,param){try{if(this.widget&&this.widget[fctName])this.widget[fctName](param)}catch(e){console.error("SC safecall error",e.stack)}};function unwrapUrl(url){return/(soundcloud\.com)\/player\/?\?.*url\=([^\&\?]+)/.test(url)?decodeURIComponent(RegExp.lastParen):url.replace(/^\/sc\//,"http://soundcloud.com/")}Player.prototype.getEid=function(url){url=unwrapUrl(url);if(/(soundcloud\.com)\/([\w-_\/]+)/.test(url)){var parts=RegExp.lastParen.split("/");return parts.length===2&&RegExp.lastParen}};function searchTracks(query,limit,cb){function waitFor(objName,cb){setTimeout((function(){if(window[objName])cb(window[objName]);else waitFor(objName,cb)}),200)}function translateResult(r){r.title=r.title||r.name;return{eId:"/sc"+r.permalink_url.substr(r.permalink_url.indexOf("/",10))+"#"+r.uri,img:r.img||r.artwork_url||"/images/cover-soundcloud.jpg",url:r.url||r.permalink_url+"#"+r.uri,title:(r.title.indexOf(" - ")==-1?r.user.username+" - ":"")+r.title,playerLabel:"Soundcloud"}}waitFor("SC",(function(SC){SC.get("/tracks",{q:query,limit:limit},(function(results){if(results instanceof Array){var tracks=results.map(translateResult);cb(tracks)}}))}))}Player.prototype.searchTracks=function(query,limit,cb){searchTracks(query,limit,cb)};Player.prototype.fetchMetadata=function(url,cb){const id=this.getEid(url);const parts=(id??"").split("/");return cb(parts.length===2&&parts[0]!=="tracks"?{id:id,eId:"/sc/"+id,img:undefined,url:"https://soundcloud.com/"+id,title:parts[0].replace(/[\-_]+/g," ")+" - "+parts[1].replace(/[\-_]+/g," "),playerLabel:"Soundcloud"}:undefined)};Player.prototype.getTrackPosition=async function(callback){const ms=this.widget?await new Promise((resolve=>this.widget.getPosition(resolve))):null;if(ms){this.trackInfo.position=ms/1e3;callback(this.trackInfo.position)}};Player.prototype.setTrackPosition=function(pos){this.safeCall("seekTo",pos*1e3)};Player.prototype.play=function(id){console.log("sc PLAY id:",id);this.trackInfo={};let url;if(id.startsWith("snd.sc")){console.error("cannot play soundcloud id:",id);return}else if(id.startsWith("tracks/")){url="https://api.soundcloud.com/"+id}else{url="https://soundcloud.com/"+id}console.log("=> sc PLAY url:",url);this.embedVars.playerContainer.innerHTML="";this.element=document.createElement("iframe");this.element.id=this.embedVars.playerId;this.element.setAttribute("width","100%");this.element.setAttribute("height","100%");this.element.setAttribute("scrolling","no");this.element.setAttribute("frameborder","no");this.element.setAttribute("allow","autoplay");console.log("=> sc PLAY url:",url);this.element.setAttribute("src",`https://w.soundcloud.com/player/?url=${encodeURIComponent(url)}&auto_play=false`);this.embedVars.playerContainer.appendChild(this.element);this.embedVars.trackId=id;const SC=window.SC;this.widget=SC.Widget(this.element);this.widget.bind(SC.Widget.Events.ERROR,(err=>{const error="error displayed in embed";console.error("SC error: ",error);this.callHandler("onError",{error:error,source:"SoundCloudPlayer"})}));this.widget.bind(SC.Widget.Events.PLAY,(()=>this.callHandler("onPlaying",this)));this.widget.bind(SC.Widget.Events.PAUSE,(()=>this.callHandler("onPaused",this)));this.widget.bind(SC.Widget.Events.FINISH,(()=>this.callHandler("onEnded",this)));this.widget.bind(SC.Widget.Events.PLAY_PROGRESS,(({currentPosition:currentPosition})=>{this.trackInfo.position=currentPosition/1e3;this.eventHandlers.onTrackInfo&&this.eventHandlers.onTrackInfo(this.trackInfo)}));this.widget.bind(SC.Widget.Events.READY,(()=>{console.log("READY");this.widget.getDuration((ms=>{this.trackInfo.duration=ms/1e3}));this.widget.play();this.callHandler("onEmbedReady",this)}))};Player.prototype.resume=function(){this.safeCall("play")};Player.prototype.pause=function(){this.safeCall("pause")};Player.prototype.stop=function(){this.embedVars.playerContainer.innerHTML="";this.element=null;this.widget=null;this.trackInfo={}};Player.prototype.setVolume=function(vol){this.safeCall("setVolume",100*vol)};SoundCloudPlayer.prototype=Player.prototype;SoundCloudPlayer.super_=Player})();try{module.exports=SoundCloudPlayer}catch(e){}function SpotifyPlayer(){return SpotifyPlayer.super_.apply(this,arguments)}(function(){var EVENT_MAP={onplay:"onPlaying",onresume:"onPlaying",onpause:"onPaused",onstop:"onPaused",onfinish:"onEnded"};function Player(eventHandlers,embedVars){var that=this;this.label="Spotify track";this.eventHandlers=eventHandlers||{};this.embedVars=embedVars||{};this.widget=null;this.isReady=false;this.trackInfo={};this.soundOptions={id:null,url:null,autoLoad:true,autoPlay:true,ontimeout:function(e){eventHandlers.onError&&eventHandlers.onError(that,{code:"timeout",source:"SpotifyPlayer"})}};Object.keys(EVENT_MAP).map((function(i){that.soundOptions[i]=function(){var handler=eventHandlers[EVENT_MAP[i]];handler&&handler(that)}}));window.soundManager.onready((function(){that.isReady=true;eventHandlers.onApiReady&&eventHandlers.onApiReady(that)}))}Player.prototype.getEid=function(url){return/spotify.com\/track\/(\w+)/.test(url)?RegExp.$1:null};Player.prototype.getTrackInfo=function(callback){var that=this,i=setInterval((function(){if(that.widget&&that.widget.duration){clearInterval(i);callback(that.trackInfo={duration:that.widget.duration/1e3,position:that.widget.position/1e3})}}),500)};Player.prototype.getTrackPosition=function(callback){var that=this;this.getTrackInfo((function(){callback(that.trackInfo.position);that.eventHandlers.onTrackInfo&&that.eventHandlers.onTrackInfo(that.trackInfo)}))};Player.prototype.setTrackPosition=function(pos){this.widget&&this.widget.setPosition(Math.floor(Math.min(this.widget.duration,pos*1e3)-2e3))};Player.prototype.embed=function(vars){var that=this;if(!vars||!vars.trackId)return;this.embedVars=vars=vars||{};this.soundOptions.id=vars.playerId=vars.playerId||"mp3Player"+(new Date).getTime();loader.loadJSON("https://api.spotify.com/v1/tracks/"+vars.trackId,(function(data){that.soundOptions.url=data.preview_url;that.trackInfo={};if(that.widget){that.pause();that.widget=null;delete that.widget}that.widget=soundManager.createSound(that.soundOptions);that.eventHandlers.onEmbedReady&&that.eventHandlers.onEmbedReady(that);that.eventHandlers.onTrackInfo&&that.getTrackInfo(that.eventHandlers.onTrackInfo);that.play()}))};Player.prototype.play=function(id){this.isReady&&this.embed({trackId:id})};Player.prototype.resume=function(){this.isReady&&this.widget&&this.widget.resume()};Player.prototype.pause=function(){try{this.isReady&&this.widget&&this.widget.pause()}catch(e){console.error("spotify error:",e,e.stack)}};Player.prototype.stop=function(){this.widget&&this.widget.stop()};Player.prototype.setVolume=function(vol){if(this.widget&&this.widget.setVolume&&this.soundOptions)soundManager.setVolume(this.soundOptions.id,100*vol)};SpotifyPlayer.prototype=Player.prototype;SpotifyPlayer.super_=Player})();try{module.exports=SpotifyPlayer}catch(e){}function VimeoPlayer(){return VimeoPlayer.super_.apply(this,arguments)}(function(){var EVENT_MAP={playProgress:function(that,data){that.trackInfo.position=Number(data.seconds);that.trackInfo.duration=Number(data.duration);that.eventHandlers.onPlaying&&that.eventHandlers.onPlaying(that);that.eventHandlers.onTrackInfo&&that.eventHandlers.onTrackInfo(that.trackInfo)},pause:"onPaused",finish:"onEnded"};function param(obj){return Object.keys(obj).map((function(f){return encodeURIComponent(f)+"="+encodeURIComponent(obj[f])})).join("&")}function onMessageReceived(e){if(e.origin.indexOf("vimeo.com")==-1)return;try{var that=this,data={};if(e.data.charAt(0)==="{"){data=JSON.parse(e.data)}else{e.data.split("&").map((function(keyval){var s=keyval.split("=");data[s[0]]=s[1]}))}data.params=(data.params||"").split(",");data.player_id=data.player_id||data.params.pop();if(data.player_id==this.embedVars.playerId){if(data.method=="onLoad"){Object.keys(EVENT_MAP).map(this.post.bind(this,"addEventListener"))}else setTimeout((function(){var eventHandler=that.eventHandlers[EVENT_MAP[data.event]]||EVENT_MAP[data.event];if(typeof eventHandler=="function")eventHandler.apply(that,[that].concat(data.data));else console.warn("vimeo missing handler for event",data.method)}))}}catch(e){console.log("VimeoPlayer error",e,e.stack);this.eventHandlers.onError&&this.eventHandlers.onError(this,{source:"VimeoPlayer",exception:e})}}function Player(eventHandlers,embedVars){var that=this;this.label="Vimeo";this.element=null;this.eventHandlers=eventHandlers||{};this.embedVars=embedVars||{};this.isReady=false;this.trackInfo={};if(window.addEventListener)window.addEventListener("message",onMessageReceived.bind(this),false);else window.attachEvent("onmessage",onMessageReceived.bind(this),false);that.isReady=true;eventHandlers.onApiReady&&eventHandlers.onApiReady(that)}Player.prototype.post=function(action,value){var data={method:action};if(value)data.value=value;try{return this.element.contentWindow.postMessage(JSON.stringify(data),this.element.src.split("?")[0])}catch(e){console.log(e)}};Player.prototype.getEid=function(url){return/(vimeo\.com\/(clip\:|video\/)?|\/vi\/)(\d+)/.test(url)&&RegExp.lastParen};function fetchMetadata(id,cb){loader.loadJSON("https://vimeo.com/api/v2/video/"+id+".json",(function(data){cb(!data||!data.map?null:{id:id,title:data[0].title,img:data[0].thumbnail_medium})}))}Player.prototype.fetchMetadata=function(url,cb){var id=this.getEid(url);if(!id)return cb();fetchMetadata(id,cb)};Player.prototype.setTrackPosition=function(pos){this.pause();this.post("seekTo",pos);this.resume()};Player.prototype.embed=function(vars){this.embedVars=vars=vars||{};this.embedVars.playerId=this.embedVars.playerId||"viplayer";this.trackInfo={};this.element=document.createElement("iframe");var attributes={id:this.embedVars.playerId,width:this.embedVars.width||"200",height:this.embedVars.height||"200",frameborder:"0",webkitAllowFullScreen:true,mozallowfullscreen:true,allowScriptAccess:"always",allowFullScreen:true,allow:"autoplay; encrypted-media",src:"https://player.vimeo.com/video/"+vars.videoId+"?"+param({api:1,js_api:1,player_id:this.embedVars.playerId,title:0,byline:0,portrait:0,autoplay:1})};for(i in attributes)this.element.setAttribute(i,attributes[i]);this.embedVars.playerContainer.innerHTML="";this.embedVars.playerContainer.appendChild(this.element);if(this.eventHandlers.onEmbedReady)this.eventHandlers.onEmbedReady()};Player.prototype.play=function(id){if(id&&(!this.currentId||this.currentId!=id)){this.embedVars.videoId=id;this.embed(this.embedVars)}};Player.prototype.resume=function(){this.post("play")};Player.prototype.pause=function(){this.post("pause")};Player.prototype.stop=function(){if(this.element)this.post("unload");if((this.element||{}).parentNode)this.element.parentNode.removeChild(this.element);if((this.otherElement||{}).parentNode)this.otherElement.parentNode.removeChild(this.otherElement)};Player.prototype.setVolume=function(vol){this.post("setVolume",100*vol)};VimeoPlayer.prototype=Player.prototype;VimeoPlayer.super_=Player})();try{module.exports=VimeoPlayer}catch(e){}window.$=window.$||function(){return window.$};$.show=$.show||function(){return $};$.attr=$.attr||function(){return $};$.getScript=$.getScript||function(js,cb){loader.includeJS(js,cb)};function YoutubePlayer(){return YoutubePlayer.super_.apply(this,arguments)}(function(){var EVENT_MAP={0:"onEnded",1:"onPlaying",2:"onPaused"},PLAYER_API_SCRIPT="https://www.youtube.com/iframe_api",PLAYER_API_LOADED=false,NOEMBED_URL="https://noembed.com/embed",YOUTUBE_VIDEO_URL="https://www.youtube.com/watch?v=",DEFAULT_PARAMS={width:"200",height:"200",playerVars:{autoplay:1,version:3,enablejsapi:1,controls:0,modestbranding:1,showinfo:0,wmode:"opaque",iv_load_policy:3,allowscriptaccess:"always"}};function whenApiReady(cb){setTimeout((function(){if(PLAYER_API_LOADED){cb()}else{whenApiReady(cb)}}),200)}window.onYouTubeIframeAPIReady=function(){PLAYER_API_LOADED=true};$.getScript(PLAYER_API_SCRIPT,(function(){}));function Player(eventHandlers,embedVars){this.eventHandlers=eventHandlers||{};this.embedVars=embedVars||{};this.label="Youtube";this.isReady=false;this.trackInfo={};this.player={};var that=this;window.onYoutubeStateChange=function(newState){if(newState.data==YT.PlayerState.PLAYING){that.trackInfo.duration=that.player.getDuration()}var eventName=EVENT_MAP[newState.data];if(eventName&&that.eventHandlers[eventName])that.eventHandlers[eventName](that)};window.onYoutubeError=function(error){eventHandlers.onError&&eventHandlers.onError(that,{source:"YoutubePlayer",code:error})};whenApiReady((function(){that.isReady=true;if(that.eventHandlers.onApiReady)that.eventHandlers.onApiReady(that)}))}Player.prototype.safeCall=function(fctName,param){try{var args=Array.apply(null,arguments).slice(1),fct=(this.element||{})[fctName];fct&&fct.apply(this.element,args)}catch(e){console.error("YT safecall error",e,e.stack)}};Player.prototype.safeClientCall=function(fctName,param){try{if(this.eventHandlers[fctName])this.eventHandlers[fctName](param)}catch(e){console.error("YT safeclientcall error",e.stack)}};Player.prototype.embed=function(vars){this.embedVars=vars=vars||{};this.embedVars.playerId=this.embedVars.playerId||"ytplayer";this.trackInfo={};this.embedVars.playerContainer.innerHTML="";this.element=document.createElement("div");this.element.id=this.embedVars.playerId;this.embedVars.playerContainer.appendChild(this.element);$(this.element).show();var that=this;that.player=new YT.Player(that.embedVars.playerId||"ytplayer",DEFAULT_PARAMS);that.player.addEventListener("onStateChange","onYoutubeStateChange");that.player.addEventListener("onError","onYoutubeError");that.element=that.player.getIframe();that.player.addEventListener("onReady",(function(event){that.safeClientCall("onEmbedReady");that.player.loadVideoById(that.embedVars.videoId)}))};Player.prototype.getEid=function(url){if(/(youtube\.com\/(v\/|embed\/|(?:.*)?[\?\&]v=)|youtu\.be\/)([a-zA-Z0-9_\-]+)/.test(url)||/^\/yt\/([a-zA-Z0-9_\-]+)/.test(url)||/youtube\.com\/attribution_link\?.*v\%3D([^ \%]+)/.test(url)||/youtube.googleapis.com\/v\/([a-zA-Z0-9_\-]+)/.test(url))return RegExp.lastParen};function searchTracks(query,limit,cb){if(!cb)return;cb([],new Error("searchTracks is not supported without a YouTube API key. Please implement a custom search solution."))}Player.prototype.searchTracks=function(query,limit,cb){searchTracks(query,limit,cb)};function fetchMetadata(id,cb){var url=YOUTUBE_VIDEO_URL+id;var noembedUrl=NOEMBED_URL+"?url="+encodeURIComponent(url);var xhr=new XMLHttpRequest;xhr.open("GET",noembedUrl);xhr.onload=function(){if(xhr.status===200){try{var data=JSON.parse(xhr.responseText);if(data.error){console.error("fetchMetadata - noembed error:",data.error);cb()}else{cb({id:id,eId:"/yt/"+id,img:data.thumbnail_url,url:url,title:data.title,playerLabel:"Youtube"})}}catch(e){console.error("fetchMetadata - JSON parse error:",e);cb()}}else{console.error("fetchMetadata - HTTP error:",xhr.status);cb()}};xhr.onerror=function(){console.error("fetchMetadata - network error");cb()};xhr.send()}Player.prototype.fetchMetadata=function(url,cb){var id=this.getEid(url);if(!id)return cb();else fetchMetadata(id,cb)};function cleanId(id){return/([a-zA-Z0-9_\-]+)/.test(id)&&RegExp.lastParen}Player.prototype.play=function(id){id=cleanId(id);if(!this.currentId||this.currentId!=id){this.embedVars.videoId=id;this.embed(this.embedVars)}};Player.prototype.pause=function(){if(this.player&&this.player.pauseVideo)this.player.pauseVideo()};Player.prototype.resume=function(){if(this.player&&this.player.playVideo)this.player.playVideo()};Player.prototype.stop=function(){try{this.player.stopVideo()}catch(e){}};Player.prototype.getTrackPosition=function(callback){if(callback&&this.player&&this.player.getCurrentTime)callback(this.player.getCurrentTime())};Player.prototype.setTrackPosition=function(pos){if(this.player&&this.player.seekTo)this.player.seekTo(pos)};Player.prototype.setVolume=function(vol){if(this.player&&this.player.setVolume)this.player.setVolume(vol*100)};YoutubePlayer.prototype=Player.prototype;YoutubePlayer.super_=Player})();try{module.exports=YoutubePlayer}catch(e){}