-
Notifications
You must be signed in to change notification settings - Fork 1
/
mcplayer.min.js
63 lines (63 loc) · 32.5 KB
/
mcplayer.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* https://www.axel-hahn.de/ */
var mcPlayer=function(k){this.cfg={about:{version:"1.03",label:"AMC Player",description:"<strong>A</strong>xels <strong>M</strong>ulti <strong>C</strong>hannel <strong>Player</strong>.<br>This is a webbased HTML5 audio player.<br>It's focus is the handling of media in stereo and surround for a title.",labeldownload:"Download:<br>",download:"http://sourceforge.net/projects/amcplayer/files/latest/download",labellicense:"License: ",license:"GPL 3.0",labelurl:"Project url:<br>",url:"https://github.com/axelhahn/amcplayer/",
labeldocurl:"Documentation:<br>",docurl:"https://www.axel-hahn.de/docs/amcplayer/index.htm"},links:{play:{title:"play"}},aPlayer:{buttons:{play:{sticky:!0,title:"Play"},pause:{sticky:!0,title:"Pause"},stop:{sticky:!0,title:"Stop"},backward:{sticky:!1,title:"Back"},forward:{sticky:!1,title:"Forward"},jumpprev:{sticky:!1,title:"Previous title"},jumpnext:{sticky:!1,title:"Next title"},audiochannels:{title:"switch between stereo/ surround",noswitch:"stereo/ surround switch was deactivated (mobile device or Opera Presto engine)"},
volmute:{visible:!0,title:"Mute"},volfull:{visible:!0,title:"Max. volume"},about:{visible:!0,title:"about ...",box:"mcpabout"},playlist:{visible:!0,title:"Toggle playlist",box:"mcpplaylist"},repeat:{visible:!0,title:"Repeat"},shuffle:{visible:!0,title:"Shuffle"},download:{visible:!0,title:"Toggle download list",box:"mcpdownloads"},maximize:{label:"Player",sticky:!1,title:"Show player"},minimize:{label:"",sticky:!1,title:"Minimize"},statusbar:{label:"",title:"Toggle statusbar with network activity and media status"}},
bars:{volume:{visible:!0,title:"Set volume"},progress:{visible:!0,title:"Set position"}},about:{title:"About ..."},playlist:{title:"Playlist"},download:{title:"Download audio files",noentry:"Select or play an audio first to show its downloads.",hint:"Use the right mousebutton or context menu to save the link target"},songinfo:{album:"Album",year:"Year",bpmspeed:"Speed",bpm:"bpm",genre:"Genre",url:"Web"},status:{networkstate:{label:"Network activity",0:["Empty","0 = NETWORK_EMPTY - audio/video has not yet been initialized"],
1:["Idle","1 = NETWORK_IDLE - audio/video is active and has selected a resource, but is not using the network"],2:["Loading","2 = NETWORK_LOADING - browser is downloading data"],3:["No Source","3 = NETWORK_NO_SOURCE - no audio/video source found"]},readystate:{label:"Status",0:["Have nothing","0 = HAVE_NOTHING - no information whether or not the audio/video is ready"],1:["Have Metadata","1 = HAVE_METADATA - metadata for the audio/video is ready"],2:["OK, Current data","2 = HAVE_CURRENT_DATA - data for the current playback position is available, but not enough data to play next frame/millisecond"],
3:["OK, Future data","3 = HAVE_FUTURE_DATA - data for the current and at least the next frame is available"],4:["OK, Enough data","4 = HAVE_ENOUGH_DATA - enough data available to start playing"]}}},settings:{autoopen:!1,movable:!0,repeatlist:!0,showsonginfos:!0,showhud:!0,showstatusbar:!1,shuffle:!1,volume:.9}};this.sCurrentChannel=this.oAudio=!1;this.iMaxVol=1;this.bIsFading=this.iCurrentTime=!1;this.iVolInc=.02;this.iTimer=20;this.iHudTimer=5;this.iRemoveTimer=2;this.aPL=[];this.iCurrentSong=-1;
this.aPlayorderList=[];this.iPlaylistId=-1;this._iMinDelta=100;this.name=this.sScreensize=this._sContainerId=!1;this.playlink="[title]";this.canPlaySurround=function(){var a=!0;0<=navigator.userAgent.indexOf("Presto/")&&(a=!1);var b=navigator.userAgent||navigator.vendor||window.opera;if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(b)||
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(b.substr(0,
4)))a=!1;return a};this._scanAudios=function(){for(var a=document.getElementsByTagName("AUDIO"),b,c,d,e=0;e<a.length;e++){a[e].style.display="none";d={title:a[e].dataset.title?a[e].dataset.title:a[e].title?a[e].title:"",artist:a[e].dataset.artist?a[e].dataset.artist:!1,album:a[e].dataset.album?a[e].dataset.album:!1,year:a[e].dataset.year?a[e].dataset.year:!1,image:a[e].dataset.image?a[e].dataset.image:!1,genre:a[e].dataset.genre?a[e].dataset.genre:!1,bpm:a[e].dataset.bpm?a[e].dataset.bpm:!1,url:a[e].dataset.url?
a[e].dataset.url:!1,sources:{}};for(var g=0;g<a[e].children.length;g++)b=a[e].children[g],"SOURCE"===b.tagName&&(c="any",b.title&&(c=b.title),b={src:b.src,type:b.type},d.sources[c]||(dummy=d.sources[c]=[]),dummy=d.sources[c].push(b));this.addAudio(d);c=document.createElement("A");c.href="#";c.title=this.cfg.links.play.title+": "+d.title;c.innerHTML=this.playlink.replace("[title]","");c.setAttribute("onclick",this.name+".setSong("+e+"); /* "+this.name+".maximize(); */ return false;");c.setAttribute("class",
"songbtn icon-play");c.setAttribute("id","mcpaudioPlay"+e);a[e].parentNode.appendChild(c)}return[]};this.addAudio=function(a){if(!a.sources)return!1;a.title||(a.title="audio "+(this.aPL.length+1));this.aPL.push(a);this._generatePlayorder()};this._genPlayer=function(){var a='<div id="mcpplayersonginfo"></div>';var b=["play","pause","stop","backward","forward"];1<this.aPL.length&&b.push("jumpprev","jumpnext");a+='<div id="mcpplayerbtndiv">';for(var c=0;c<b.length;c++)a+='<a href="#" id="mcp'+b[c]+'" onclick="'+
this.name+".playeraction('"+b[c]+'\'); return false;" title="'+this.cfg.aPlayer.buttons[b[c]].title+'"></a>';a+='</div><div id="mcpprogressdiv"'+(this.cfg.aPlayer.bars.progress.visible?"":'style="display: none"')+'><div class="mcpslider"><div class="mcpslider-default"></div><div id="mcpprogressbar" class="mcpslider-active"></div></div></div><span id="mcptime"><span id="mcptimeplayed">-:--</span>/ <span id="mcptimetotal">-:--</span></span><div id="mcpvolumesection"><a href="#" id="mcpvolmute" onclick="'+
this.name+'.setVolume(0); return false;" '+(this.cfg.aPlayer.buttons.volmute.visible?"":'style="display: none" ')+'title="'+this.cfg.aPlayer.buttons.volmute.title+'"></a><div id="mcpvolumediv" title="volume"><div class="mcpslider"><div class="mcpslider-default"></div><div id="mcpvolumebar" class="mcpslider-active"></div></div></div><a href="#" id="mcpvolfull" onclick="'+this.name+'.setVolume(1); return false;" '+(this.cfg.aPlayer.buttons.volfull.visible?"":'style="display: none" ')+'title="'+this.cfg.aPlayer.buttons.volfull.title+
'"></a></div><div id="mcpchannels"></div><div id="mcpoptions"><a href="#" onclick="'+this.name+'.toggleRepeat(); return false;" id="mcpoptrepeat" '+(this.isRepeatlist()?'class="active" ':"")+'title="'+this.cfg.aPlayer.buttons.repeat.title+'"></a><a href="#" onclick="'+this.name+'.toggleShuffle(); return false;" id="mcpoptshuffle" '+(this.cfg.settings.shuffle?'class="active" ':"")+'title="'+this.cfg.aPlayer.buttons.shuffle.title+'"></a><a href="#" onclick="'+this.name+'.toggleStatusbar(); return false;" id="mcpoptstatusbar" '+
(this.isVisibleStatusbar()?'class="active" ':"")+'title="'+this.cfg.aPlayer.buttons.statusbar.title+'"></a>';b=["download","playlist","about"];for(c=0;c<b.length;c++)idLink="mcpopt"+b[c],a+='<a href="#" onclick="'+this.name+".toggleBoxAndButton('"+b[c]+'\'); return false;" id="mcpopt'+b[c]+'" '+(this.cfg.aPlayer.buttons[b[c]].visible?"":'style="display: none" ')+' title="'+this.cfg.aPlayer.buttons[b[c]].title+'"></a>';return a+='</div><div id="mcpstatusbar"'+(this.cfg.settings.showstatusbar?' class="active" ':
"")+"><div>"+this.cfg.aPlayer.status.networkstate.label+': <span id="mcpstatusnetwork"></span></div><div>'+this.cfg.aPlayer.status.readystate.label+': <span id="mcpstatusready"></span></div></div>'};this._genAboutbox=function(){return'<div class="mcpbox"><span class="ico-about"> '+this.cfg.aPlayer.about.title+'</span><span class="mcpsystembutton"><a href="#" class="icon-down-open-1" onclick="'+this.name+".toggleBoxAndButton('about', 'minimize'); return false;\" title=\""+this.cfg.aPlayer.buttons.minimize.title+
'">'+this.cfg.aPlayer.buttons.minimize.label+'</a></span></div><div><p class="amclogo"></p><div class="title">'+this.cfg.about.label+" v"+this.cfg.about.version+"</div><p>"+this.cfg.about.description+"</p><p>"+this.cfg.about.labellicense+this.cfg.about.license+"</p><p>"+this.cfg.about.labelurl+'<a href="'+this.cfg.about.url+'" target="_blank">'+this.cfg.about.url+"</a></p><p>"+this.cfg.about.labeldownload+'<a href="'+this.cfg.about.download+'" target="_blank">'+this.cfg.about.download+"</a></p><p>"+
this.cfg.about.labeldocurl+'<a href="'+this.cfg.about.docurl+'" target="_blank">'+this.cfg.about.docurl+"</a></p></div>"};this._genPlaylist=function(){var a='<div class="mcpbox"><span class="ico-playlist"> '+this.cfg.aPlayer.playlist.title+'</span><span class="mcpsystembutton"><a href="#" class="icon-down-open-1" onclick="'+this.name+".toggleBoxAndButton('playlist', 'minimize'); return false;\" title=\""+this.cfg.aPlayer.buttons.minimize.title+'">'+this.cfg.aPlayer.buttons.minimize.label+"</a></span></div>";
if(0<this.aPL.length){a+="<ul>";for(var b=0;b<this.aPL.length;b++)a+="<li"+(this.iCurrentSong===b?' class="active"':"")+'><a href="#" onclick="'+this.name+".setSong("+b+'); return false;">'+(this.aPL[b].title?this.aPL[b].title:"Audio #"+(b+1))+"</a></li>";a+="</ul>"}return a};this._genSonginfos=function(){if(!this.cfg.settings.showsonginfos)return"";var a=(this.getSongArtist()?'<div class="artist">'+this.getSongArtist()+"</div>":"")+(this.getSongAlbum()?'<div class="album">'+this.cfg.aPlayer.songinfo.album+
": "+this.getSongAlbum()+"</div>":"")+(this.getSongYear()?'<div class="year">'+this.cfg.aPlayer.songinfo.year+": "+this.getSongYear()+"</div>":"")+(this.getSongBpm()?'<div class="bpm">'+this.cfg.aPlayer.songinfo.bpmspeed+": "+this.getSongBpm()+" "+this.cfg.aPlayer.songinfo.bpm+"</div>":"")+(this.getSongGenre()?'<div class="genre">'+this.cfg.aPlayer.songinfo.genre+": "+this.getSongGenre()+"</div>":"")+(this.getSongUrl()?'<div class="url">'+this.cfg.aPlayer.songinfo.url+': <a href="'+this.getSongUrl()+
'" target="_blank">'+this.getSongUrl()+"</a></div>":"");if(a||this.getSongImage())a="<div>"+(this.getSongImage()?'<img src="'+this.getSongImage()+'">':"")+(this.getSongTitle()?'<div class="title">'+this.getSongTitle()+"</div>":"")+a,a+='<div style="clear: both;"></div></div>';return a};this._genDownloads=function(){var a="";if(0<this.aPL.length){a+='<div class="mcpbox"><span class="ico-download"> '+this.cfg.aPlayer.download.title+'</span><span class="mcpsystembutton"><a href="#" class="icon-down-open-1" onclick="'+
this.name+".toggleBoxAndButton('download', 'minimize'); return false;\" title=\""+this.cfg.aPlayer.buttons.minimize.title+'">'+this.cfg.aPlayer.buttons.minimize.label+"</a></span></div><ul>";if(-1===this.iCurrentSong)a+="<li>"+this.cfg.aPlayer.download.noentry+"</li>";else{a+="<li>"+this.cfg.aPlayer.download.hint+"<br><br></li>";for(var b=0;b<this.aPL.length;b++)if((sSong=this.aPL[b].title)||(sSong="Audio #"+(b+1)),-1===this.iCurrentSong||this.iCurrentSong==b){a+="<li "+(this.iCurrentSong==b?' class="active"':
"")+"><strong>"+sSong+"</strong><ul>";for(var c in this.aPL[b].sources){a+="<li>"+c+": ";for(j=0;j<this.aPL[b].sources[c].length;j++)sSrc=this.aPL[b].sources[c][j].src,(sExt=this.aPL[b].sources[c][j].type.replace("audio/",""))||(sExt=this.aPL[b].sources[c][j].src.replace(/^.*\/|\.[^.]*$/g,"")),a+=(0<j?" | ":"")+'<a href="'+this.aPL[b].sources[c][j].src+'" title="'+sSong+" ("+c+"; "+sExt+")\n"+this.aPL[b].sources[c][j].src+'">'+sExt+"</a>";a+="</li>"}a+="</ul></li>"}}a+="</ul>"}return a};this._generatePlaylist=
function(){this._scanAudios();this._generatePlayorder()};this._randomSort=function(a,b){return parseInt(10*Math.random())%2};this._generatePlayorder=function(){this.aPlayorderList=[];if(this.aPL.length){for(var a=0;a<this.aPL.length;a++)this.aPlayorderList[a]=a;this.isShuffled()&&(0<=this.iCurrentSong&&this.aPlayorderList.splice(this.iCurrentSong,1),this.aPlayorderList.sort(this._randomSort),0<=this.iCurrentSong&&this.aPlayorderList.unshift(this.iCurrentSong));this._findPlaylistId()}};this._findPlaylistId=
function(){this.iPlaylistId=!1;if(0<=this.iCurrentSong)for(var a=0;a<this.aPlayorderList.length;a++)this.aPlayorderList[a]===this.iCurrentSong&&(this.iPlaylistId=a);return this.iPlaylistId};this._addHtml=function(a){if(oContainer=document.getElementById(this._sContainerId)?document.getElementById(this._sContainerId):document.getElementsByTagName("BODY")[0])oContainer.innerHTML+=a};this._initHtml=function(){var a=' style="top: '+(document.documentElement.clientHeight+100+"px")+';"';this.oDivDownloads=
document.getElementById("mcpdownloads");this.oDivDownloads||(this._addHtml('<div id="mcpdownloads" class="draggable saveposition"'+a+"></div>"),this.oDivDownloads=document.getElementById("mcpdownloads"));this.oDivDownloads.innerHTML=this._genDownloads();this.oDivPlaylist=document.getElementById("mcpplaylist");this.oDivPlaylist||(this._addHtml('<div id="mcpplaylist" class="draggable saveposition"'+a+"></div>"),this.oDivPlaylist=document.getElementById("mcpplaylist"));this.oDivPlaylist.innerHTML=this._genPlaylist();
this.oDivPlayerwrapper=document.getElementById("mcpwrapper");this.oDivPlayerwrapper||(this._addHtml('<div id="mcpwrapper"'+(this.cfg.settings.movable?' class="draggable saveposition"':"")+"></div>"),this.oDivPlayerwrapper=document.getElementById("mcpwrapper"));this.oDivHeader=document.getElementById("mcpheader");this.oDivHeader||(this.oDivPlayerwrapper.innerHTML+='<div id="mcpheader" class="mcpbox"><span class="ico-playlist"> '+this.cfg.about.label+" v"+this.cfg.about.version+' <span id="mcptitle"></span><span class="mcpsystembutton"><a href="#" class="icon-down-open-1" onclick="'+
this.name+'.minimize(); return false" title="'+this.cfg.aPlayer.buttons.minimize.title+'">'+this.cfg.aPlayer.buttons.minimize.label+"</a></span></div>");this.oDivAudios||(this.oDivPlayerwrapper.innerHTML+='<div id="mcpplayeraudios"></div>',this.oDivAudios=document.getElementById("mcpplayeraudios"));this.oDivPlayer=document.getElementById("mcplayer");this.oDivPlayer||(this.oDivPlayerwrapper.innerHTML+='<div id="mcplayer"></div>',this.oDivPlayer=document.getElementById("mcplayer"),this.oDivPlayer.innerHTML=
this._genPlayer());this.oAPlayermaximize=document.getElementById("mcpmaximize");this.oAPlayermaximize||(this._addHtml('<a href="#" id="mcpmaximize" class="mcpsystembutton hidebutton" onclick="'+this.name+'.maximize(); return false" title="'+this.cfg.aPlayer.buttons.maximize.title+'"> '+this.cfg.aPlayer.buttons.maximize.label+"</a>"),this.oAPlayermaximize=document.getElementById("mcpmaximize"));this._addHtml('<div id="mcpabout" class="draggable saveposition"'+a+">"+this._genAboutbox()+"</div>");this.oDivPlayerhud=
document.getElementById("mcphud");this.oDivPlayerhud||(this._addHtml('<div id="mcphud"></div>'),this.oDivPlayerhud=document.getElementById("mcphud"));this._playerheightSet()};this.minimize=function(a){o=document.getElementById("mcpwrapper");o.style["transition-duration"]=a?"0s":"";o.style.top=document.documentElement.clientHeight+this._iMinDelta+"px";this.minimizeBox("about");this.minimizeBox("download");this.minimizeBox("playlist");document.getElementById("mcpmaximize").className=""};this.makeMainwindowMovable=
function(a){this.cfg.settings.movable=a;o=document.getElementById("mcpwrapper");this.cfg.settings.movable&&(o.className="draggable saveposition","undefined"!==typeof addi?addi.initDiv(o):this.cfg.settings.movable=!1);this.cfg.settings.movable||(o.className="","undefined"!==typeof addi&&addi.resetDiv(o),this.maximize(),o.setAttribute("style",""))};this.maximize=function(){o=document.getElementById("mcpwrapper");o.setAttribute("style","");this.cfg.settings.movable&&"undefined"!==typeof addi&&addi.load(document.getElementById("mcpwrapper"));
document.getElementById("mcpmaximize").className="hidebutton"};this._showInfo=function(a){if(!this.cfg.settings.showhud||this.cfg.settings.autoopen||this.isVisiblePlayer())return!1;var b=document.getElementById("mcphud");this.iRemoveTimer=1E3*this.iHudTimer;b.className="active";b.innerHTML=a;this._decHudTimer();return!0};this._hideInfo=function(){document.getElementById("mcphud").className="";return!0};this._decHudTimer=function(){this.iRemoveTimer-=100;0<this.iRemoveTimer?window.setTimeout(this.name+
"._decHudTimer()",100):(this._hideInfo(),this.iRemoveTimer=!1)};this._togglehelperGetDiv=function(a){return this.cfg.aPlayer.buttons[a]&&this.cfg.aPlayer.buttons[a].box?document.getElementById(this.cfg.aPlayer.buttons[a].box):"player"===a?document.getElementById("mcpwrapper"):!1};this.toggleBoxAndButton=function(a,b,c){var d=this._togglehelperGetDiv(a);a=document.getElementById("mcpopt"+a);b||(b=0>a.className.indexOf("active")?"maximize":"minimize");d&&(d.style["transition-duration"]=c?"0s":"");"minimize"===
b?(d&&(d.style.top=document.documentElement.clientHeight+this._iMinDelta+"px",d.style.opacity=.1),a&&(a.className="")):"maximize"===b&&(d&&(d.setAttribute("style",""),d.style.opacity=1,"undefined"!==typeof addi&&addi.load(d)),a&&(a.className="active"));return!0};this.isVisibleBox=function(a){return(a=document.getElementById("player"===a?"mcpmaximize":"mcpopt"+a))?!!a.className:!1};this.isVisibleBoxAbout=function(){return this.isVisibleBox("about")};this.isVisibleBoxDownload=function(){return this.isVisibleBox("download")};
this.isVisibleBoxPlaylist=function(){return this.isVisibleBox("playlist")};this.isVisiblePlayer=function(){return this.isVisibleBox("player")};this.isVisibleStatusbar=function(){return this.cfg.settings.showstatusbar};this.toggleRepeat=function(){return this.isRepeatlist()?this.disableRepeat():this.enableRepeat()};this.enableRepeat=function(){this.cfg.settings.repeatlist=!0;this.toggleBoxAndButton("repeat","maximize")};this.disableRepeat=function(){this.cfg.settings.repeatlist=!1;this.toggleBoxAndButton("repeat",
"minimize")};this.toggleShuffle=function(){return this.isShuffled()?this.disableShuffle():this.enableShuffle()};this.enableShuffle=function(){this.cfg.settings.shuffle=!0;this._generatePlayorder();this.toggleBoxAndButton("shuffle","maximize")};this.disableShuffle=function(){this.cfg.settings.shuffle=!1;this._generatePlayorder();this.toggleBoxAndButton("shuffle","minimize")};this._setStatusbar=function(a){this.cfg.settings.showstatusbar=!!a;this.toggleBoxAndButton("statusbar",a?"maximize":"minimize");
document.getElementById("mcpstatusbar").className=a?"active":"";this._playerheightAdjust();return!0};this.enableStatusbar=function(){return this._setStatusbar(!0)};this.disableStatusbar=function(){return this._setStatusbar(!1)};this.toggleStatusbar=function(){return this.isVisibleStatusbar()?this.disableStatusbar():this.enableStatusbar()};this.minimizeBox=function(a,b){return this.toggleBoxAndButton(a,"minimize",b)};this.maximizeBox=function(a,b){return this.toggleBoxAndButton(a,"maximize",b)};this.playeraction=
function(a){if(!this.oAudio)if("play"===a)this.setSong(this.aPlayorderList[0]);else return!1;switch(a){case "play":this.oAudio.play();break;case "pause":this.oAudio.pause();break;case "stop":this.oAudio.pause();try{this.oAudio.currentTime=0}catch(d){}break;case "forward":this.oAudio.currentTime+=10;break;case "backward":this.oAudio.currentTime-=10;break;case "jumpprev":this.setPreviousSong();break;case "jumpnext":this.setNextSong();break;default:alert("playeraction not implemented yet: ["+a+"]")}if(this.cfg.aPlayer.buttons[a].sticky){for(var b=
document.getElementById("mcpplayerbtndiv").getElementsByTagName("A"),c=0;c<b.length;c++)b[c].className="";document.getElementById("mcp"+a).className="active"}};this.setAudioPosition=function(a){return!this.sCurrentChannel||this.oAudio.duration<a?!1:this.oAudio.currentTime=a};this.setPreviousSong=function(){return this.aPlayorderList&&this.aPlayorderList.length?0<this.iPlaylistId?this.setSong(this.aPlayorderList[this.iPlaylistId-1]):this.setSong(this.aPlayorderList[this.aPlayorderList.length-1]):!1};
this.setNextSong=function(){if(!this.aPL||!this.aPL.length)return!1;if(this.iPlaylistId<this.aPlayorderList.length-1)return this.setSong(this.aPlayorderList[this.iPlaylistId+1]);this._generatePlayorder();this.isRepeatlist()&&this.setSong(this.aPlayorderList[this.isShuffled()?1:0])};this.setSong=function(a){if(!this.aPL[a]||this.bIsFading)return!1;var b="",c="",d=!1,e=!1,g=!1,l=0;if(this.oAudio){this.getVolume();this.oAudio.pause();try{this.oAudio.currentTime=0}catch(m){}this.oAudio=!1}this.oDivAudios.innerHTML=
"";for(var f in this.aPL[a].sources)if(this.aPL[a].sources[f].length){d||(d=f);e!==f&&(l++,c+="<li>",c=this.canPlaySurround()?c+('<a href="#" onclick="'+this.name+".setChannel('"+f+'\'); return false;" title="'+this.cfg.aPlayer.buttons.audiochannels.title+": "+f+'">'+f+"</a>"):c+('<a href="#" onclick="return false;" title="'+this.cfg.aPlayer.buttons.audiochannels.noswitch+'">'+f+"</a>"),c+="</li>",e=f,f===this.sCurrentChannel&&(g=!0));b+='<audio id="mcp'+f+'" >';for(h=0;h<this.aPL[a].sources[f].length;h++)source=
this.aPL[a].sources[f][h],sourcesrc=String(source.src),0>sourcesrc.indexOf("?")&&(sourcesrc+="?"),b+='<source src="'+sourcesrc+'" type="'+source.type+'">';b+="</audio>"}1===l&&(c="");document.getElementById("mcpplayeraudios").innerHTML=b;c&&(c="<ul>"+c+"</ul>");document.getElementById("mcpchannels").innerHTML=c;this.iCurrentSong=a;this._findPlaylistId();document.getElementById("mcpplaylist").innerHTML=this._genPlaylist();document.getElementById("mcpdownloads").innerHTML=this._genDownloads();this._playerheightSet();
h=this._genSonginfos();document.getElementById("mcpplayersonginfo").innerHTML=h;this._playerheightAdjust();document.getElementById("mcptitle").innerHTML=this.getSongTitle();b=document.getElementsByTagName("A");for(var h=0;h<b.length;h++)oLink=b[h],"songbtn icon-play songbtnactive"===oLink.className&&(oLink.className="songbtn icon-play");o=document.getElementById("mcpaudioPlay"+a).className+=" songbtnactive";this.iCurrentTime=!1;g&&(d=this.sCurrentChannel);this.sCurrentChannel=!1;this.setChannel(d);
this.playeraction("play",!0);this._showInfo(a+1+"/ "+this.aPL.length+"<br>«"+this.aPL[a].title+"»");this.cfg.settings.autoopen&&this.maximize();return!0};this._playerheightAdjust=function(){if("undefined"!==typeof addi&&this.cfg.settings.movable){var a=document.getElementById("mcpwrapper"),b=a.style.top.replace("px","")/1,c=b+a.clientHeight/2,d=document.documentElement.clientHeight;if(c>d/3){var e=a.clientHeight-this._iHeightPlayerWindow;a.style.top=(c>2*d/3?b-e:b-e/2)+"px"}this._playerheightSet()}};
this._playerheightSet=function(){this._iHeightPlayerWindow=document.getElementById("mcpwrapper").clientHeight};this.setChannel=function(a){var b=document.getElementById("mcpchannels").getElementsByTagName("LI");if(b.length)for(var c=0;c<b.length;c++){if((oALI=b[c].getElementsByTagName("A"))&&0<oALI.length&&(oALI[0].className="",oALI[0].innerHTML&&oALI[0].innerHTML===a)){var d=oALI[0].parentNode;oALI[0].className="active"}b[c].className=""}d&&(d.className="active");b=this.isPlaying();if(this.sCurrentChannel===
a||this.bIsFading)return!1;this.oAudio&&(this.iCurrentTime=this.oAudio.currentTime,this.getVolume(),this._fadeOut(this.sCurrentChannel));this.oAudio=!1;a&&(oAudioTmp=document.getElementById("mcp"+a),oAudioTmp.idurationchange=0,oAudioTmp.isStream=!1,oAudioTmp.lastDuration=!1,this.oAudio=oAudioTmp)&&(b&&this._wait4Audio(this.oAudio,this.iCurrentTime),this.oAudio.volume=this.cfg.settings.volume,document.getElementById("mcptimeplayed").innerHTML="?:??",document.getElementById("mcptimetotal").innerHTML=
"?:??",document.getElementById("mcptime").style.display="block",oAudioTmp.addEventListener("durationchange",function(){Infinity===oAudioTmp.duration?oAudioTmp.isStream=!0:oAudioTmp.lastDuration!==oAudioTmp.duration&&(oAudioTmp.idurationchange++,oAudioTmp.lastDuration=oAudioTmp.duration,3<oAudioTmp.idurationchange&&(oAudioTmp.isStream=!0))}),oAudioTmp.addEventListener("timeupdate",function(){document.getElementById("mcpprogressdiv").style.display=oAudioTmp.isStream?"none":"";document.getElementById("mcptime").style.display=
oAudioTmp.isStream?"none":"block";document.getElementById("mcppause").style.display=oAudioTmp.isStream?"none":"block";document.getElementById("mcpbackward").style.display=oAudioTmp.isStream?"none":"block";document.getElementById("mcpforward").style.display=oAudioTmp.isStream?"none":"block";if(!oAudioTmp.currentTime)return document.getElementById("mcptimeplayed").innerHTML="-:--",document.getElementById("mcptimetotal").innerHTML="-:--",!1;if(oAudioTmp.isStream)return!1;var a=parseInt(oAudioTmp.currentTime%
60),b=parseInt(oAudioTmp.currentTime/60%60);10>a&&(a="0"+a);var c=parseInt(oAudioTmp.duration%60),d=parseInt(oAudioTmp.duration/60%60);10>c&&(c="0"+c);document.getElementById("mcptimeplayed").innerHTML=b+":"+a;document.getElementById("mcptimetotal").innerHTML=d+":"+c;if(a=document.getElementById("mcpprogressbar"))a.style.width=oAudioTmp.currentTime/oAudioTmp.duration*100+"%"},!1),document.getElementById("mcpprogressdiv").addEventListener("click",function(a){x=void 0!==a.x&&void 0!==a.y?a.x:a.clientX+
document.body.scrollLeft+document.documentElement.scrollLeft;a=document.getElementById("mcpprogressdiv");var b=document.getElementById("mcpwrapper");x-=a.offsetLeft+b.offsetLeft;oAudioTmp&&oAudioTmp.currentTime&&(oAudioTmp.currentTime=x/a.clientWidth*oAudioTmp.duration)},!0),oAudioTmp.addEventListener("volumechange",function(){var a=document.getElementById("mcpvolumebar");a&&(a.style.width=100*oAudioTmp.volume+"%")},!1),this.oAudio.volume=this.cfg.settings.volume-.01,this.oAudio.volume=this.cfg.settings.volume,
document.getElementById("mcpvolumediv").addEventListener("click",function(a){x=void 0!==a.x&&void 0!==a.y?a.x:a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;a=document.getElementById("mcpvolumediv");var b=document.getElementById("mcpwrapper");x-=a.offsetLeft+b.offsetLeft;try{localStorage.setItem("amcp.volume",x/a.clientWidth),oAudioTmp.volume=x/a.clientWidth}catch(l){console.error("Error:"+l)}},!0),oAudioTmp.addEventListener("ended",function(){document.getElementById("mcpjumpnext").click()},
!1));this.sCurrentChannel=a;localStorage.setItem("amcp.channels",this.sCurrentChannel);return!0};this.setConfig=function(a){this.cfg=realMerge(this.cfg,a)};this.setVolume=function(a){this.cfg.settings.volume=a;localStorage.setItem("amcp.volume",this.cfg.settings.volume);return this.oAudio?(this.oAudio.volume=a,!0):!1};this._wait4Audio=function(a,b){a.volume=.001;a.play();b&&(a.currentTime=b);return!0};this._fade=function(a,b){this.bIsFading=!0;o=document.getElementById("mcp"+b);if(!o)return!1;iVol=
o.volume;iInc=a<iVol?-this.iVolInc:this.iVolInc;iVol+=iInc;0===a&&0<iVol||0<a&&iVol<a?(o.volume=iVol,window.setTimeout(this.name+"._fade("+a+", '"+b+"')",this.iTimer)):(this.bIsFading=!1,o.volume=a,0>=iVol&&o.pause());return!0};this._fadeOut=function(a){this._fade(0,a)};this.getAudioChannels=function(){return this.sCurrentChannel};this.getAllAudioChannels=function(){var a=this.getSong();if(!a)return!1;var b=[],c;for(c in a.sources)b.push(c);return b};this.getAudioDuration=function(){return this.sCurrentChannel?
this.oAudio.duration:!1};this.getAudioNetworkstate=function(){var a=this.oAudio?this.oAudio:document.getElementById("mcp"+this.getAudioChannels());return a?a.networkState:!1};this.getAudioPosition=function(){return this.sCurrentChannel?this.oAudio.currentTime:!1};this.getAudioReadystate=function(){var a=this.oAudio?this.oAudio:document.getElementById("mcp"+this.getAudioChannels());return a?a.readyState:!1};this.getAudioSrc=function(){return this.sCurrentChannel?this.oAudio.currentSrc:!1};this.getVolume=
function(){return this.oAudio?(this.cfg.settings.volume=this.oAudio.volume,this.cfg.settings.volume):!1};this.getPlaylist=function(){return this.aPL&&this.aPL.length?this.aPL:!1};this.getPlaylistCount=function(){return this.aPL?this.aPL.length:!1};this.getPlayorder=function(){return this.aPlayorderList};this.getSong=function(){return this.aPL&&this.aPL.length?this.aPL[this.iCurrentSong]:!1};this.getSongId=function(){return this.iCurrentSong};this._getSongItem=function(a){var b=this.getSong();return b?
b[a]:!1};this.getSongTitle=function(){return this._getSongItem("title")};this.getSongArtist=function(){return this._getSongItem("artist")};this.getSongAlbum=function(){return this._getSongItem("album")};this.getSongYear=function(){return this._getSongItem("year")};this.getSongImage=function(){return this._getSongItem("image")};this.getSongGenre=function(){return this._getSongItem("genre")};this.getSongBpm=function(){return this._getSongItem("bpm")};this.getSongUrl=function(){return this._getSongItem("url")};
this.getPlaylistId=function(){return this.iPlaylistId};this.isMuted=function(){return this.oAudio&&(this.oAudio.muted||!this.oAudio.volume)};this.isPaused=function(){return this.oAudio&&this.oAudio.paused&&0!==this.oAudio.currentTime};this.isPlaying=function(){return this.oAudio&&!this.oAudio.paused};this.isRepeatlist=function(){return this.cfg.settings.repeatlist?!!this.cfg.settings.repeatlist:!1};this.isShuffled=function(){return this.cfg.settings.shuffle?this.cfg.settings.shuffle:!1};this.isStopped=
function(){return!this.oAudio||0===this.oAudio.currentTime};this.isStream=function(){return this.oAudio&&this.oAudio.isStream};this.updateOnResize=function(){var a=document.documentElement.clientWidth+" x "+document.documentElement.clientHeight;if(this.sScreensize&&a==this.sScreensize)return!1;this.sScreensize=a;a=["player","about","download","playlist"];for(var b=0;b<a.length;b++){var c=a[b],d=this._togglehelperGetDiv(c),e=d.style.top.replace("px","")/1,g=d.style.left.replace("px","")/1;if(this.isVisibleBox(c)){if(0>
e||e>document.documentElement.clientHeight-50)d.style.top="player"===c?document.documentElement.clientHeight-d.clientHeight-50+"px":"";g>document.documentElement.clientWidth-d.clientWidth&&(d.style.left=document.documentElement.clientWidth-d.clientWidth+"px");0>g&&(d.style.left="0px")}else e<document.documentElement.clientHeight+this._iMinDelta&&this.toggleBoxAndButton(c,"minimize",!0)}};this.updateStatus=function(){var a=this.getAudioNetworkstate();if(a){var b=this.getAudioReadystate();document.getElementById("mcpstatusnetwork").innerHTML=
'<span class="networkstate'+a+'" title="'+this.cfg.aPlayer.status.networkstate[a][1]+'">'+this.cfg.aPlayer.status.networkstate[a][0]+"</span>";document.getElementById("mcpstatusready").innerHTML='<span class="readystate'+b+'" title="'+this.cfg.aPlayer.status.readystate[b][1]+'">'+this.cfg.aPlayer.status.readystate[b][0]+"</span>"}else document.getElementById("mcpstatusnetwork").innerHTML="-",document.getElementById("mcpstatusready").innerHTML="-";this.updateOnResize();return!0};this._getName=function(){for(var a in this.global)if(this.global[a]===
this)return this._setName(a)};this._setName=function(a){return this.name=a};this.init=function(a){this._sContainerId=a;this._getName();this._generatePlaylist();this._initHtml();"undefined"!==typeof addi&&addi.init();this.minimizeBox("about",!0);this.minimizeBox("download",!0);this.minimizeBox("playlist",!0);window.setInterval(this.name+".updateStatus()",500);return!0};k&&this.setConfig(k);this.canPlaySurround();try{this.sCurrentChannel=localStorage.getItem("amcp.channels")?localStorage.getItem("amcp.channels"):
!1,this.cfg.settings.volume=localStorage.getItem("amcp.volume")/1?localStorage.getItem("amcp.volume")/1:1}catch(a){}return!0};mcPlayer.prototype.global=this;var realMerge=function(k,a){for(var b in a)"object"!==typeof k[b]?k[b]=a[b]:"object"===typeof a[b]&&(k[b]=realMerge(k[b],a[b]));return k};