var YOBO_SP_STATUS_STOP=0;
var YOBO_SP_STATUS_LOAD=1;
var YOBO_SP_STATUS_PLAY=2;
var YOBO_SP_STATUS_PAUSE=3;
var YOBO_SL_LOOP_ORDER=0;
var YOBO_SL_LOOP_RND=1;
var YOBO_SL_LOOP_BACK=2;
Event.observe(window,"load",function(){
var _1=document.createElement("DIV");
_1.id="yobo_float_music_menu";
_1.style.position="absolute";
_1.style.display="none";
_1.style.width="84px";
_1.style.cursor="pointer";
_1.onmouseover=function(){
_1.style.display="block";
};
_1.onmouseout=function(){
_1.style.display="none";
};
document.body.appendChild(_1);
});
function yobo_song_floatmenu(_2,_3,_4){
var _5=80;
var _6=$(_3);
try{
var _7=$("yobo_float_music_menu");
if(!_7){
return false;
}
if(!_4){
_7.hide();
return;
}
var _8=Position.cumulativeOffset(_2)[0]+$(_2).getWidth()-_5-10;
var _9=Position.cumulativeOffset(_2)[1];
_7.innerHTML=_6.innerHTML;
var _a=document.createElement("input");
_a.type="hidden";
_a.name="hidden";
_a.id="yobo_songmenubar_hidden";
_7.appendChild(_a);
_a=document.createElement("input");
_a.type="hidden";
_a.name="from";
_a.id="yobo_songmenubar_from";
_7.appendChild(_a);
_a=document.createElement("input");
_a.type="hidden";
_a.name="fr";
_a.id="yobo_songmenubar_pagefrom";
_7.appendChild(_a);
_7.setStyle({left:_8+"px",top:_9+"px"});
_7.show();
}
catch(e){
}
}
if(typeof (yobo_songPlayer)!="function"){
var yobo_songPlayer=Class.create();
yobo_songPlayer.prototype={initialize:function(){
this.ext_flash=null;
this.win_flash=null;
this.dom_pagebtn=null;
this.is_pagebtn=false;
this.sp_status=YOBO_SP_STATUS_STOP;
this.sp_songlist=[];
this.is_songlist=false;
this.sp_listmethod=YOBO_SL_LOOP_ORDER;
this.sp_listcuridx=0;
this.dom_listouter=null;
this.dom_listprev=null;
this.dom_listplay=null;
this.dom_listnext=null;
this.dom_listorder=null;
this.sp_songurl="nourl";
this.sp_songid=-1;
this.sp_songrnd=-1;
this.dom_songouter=null;
this.dom_songctrl=null;
this.dom_songtable=null;
this.dom_songtime=null;
this.sp_loadtimer=null;
this.sp_looptimer=null;
this.is_init=false;
this.is_upload=false;
},initPlayer:function(){
try{
if(navigator.appName.indexOf("Microsoft")!=-1){
this.ext_flash=window["pagesongplayer"];
this.win_flash=window["finalPlayer"];
}else{
this.ext_flash=document["pagesongplayer"];
this.win_flash=document["finalPlayer"];
}
this.dom_pagebtn=$("yobo_largesongctrlbtn");
this.is_pagebtn=false;
this.sp_status=YOBO_SP_STATUS_STOP;
this.sp_songlist=[];
this.is_songlist=false;
this.sp_listmethod=YOBO_SL_LOOP_ORDER;
this.sp_listcuridx=0;
this.dom_listouter=$("yobo_songctrlbar");
this.dom_listprev=$("yobo_sctrl_prev");
this.dom_listplay=$("yobo_sctrl_play");
this.dom_listnext=$("yobo_sctrl_next");
this.dom_listorder=$("yobo_sctrl_order");
this.sp_songurl="nourl";
this.sp_songid=-1;
this.sp_songrnd=-1;
this.dom_songouter=null;
this.dom_songctrl=null;
this.dom_songtable=null;
this.dom_songtime=null;
this.sp_loadtimer=null;
this.sp_looptimer=null;
this.is_init=true;
this.is_upload=false;
}
catch(e){
traceError("Error initPlayer::initialize -> "+e);
}
},playSong:function(_b,_c,_d,_e,_f){
try{
if(this.is_init){
this.is_pagebtn=_e?true:false;
this.is_songlist=false;
this.startSong(_b,_c,_d,true,_f);
}
}
catch(e){
traceError("Error yobo_songPlayer::play -> "+e);
}
},playList:function(_10){
try{
if(this.is_init){
this.is_pagebtn=false;
if(_10&&_10.length>0){
this.is_songlist=true;
if(this.sp_songlist==_10){
this.sp_listcuridx=(this.sp_listcuridx+this.sp_songlist.length)%this.sp_songlist.length;
}else{
this.sp_songlist=_10;
this.sp_listcuridx=0;
}
var _11=this.sp_songlist[this.sp_listcuridx];
this.startSong(_11.url,_11.sid,_11.rnd,false,_11.isup);
}else{
traceError("Error yobo_songPlayer::playList -> invalid list");
}
}
}
catch(e){
traceError("Error yobo_songPlayer::playList -> "+e);
}
},initList:function(_12){
try{
if(_12&&_12.length>0){
this.sp_songlist=_12;
this.sp_listcuridx=0;
}else{
traceError("Error yobo_songPlayer::playList -> invalid list");
}
}
catch(e){
traceError("Error yobo_songPlayer::initList -> "+e);
}
},updateListMethod:function(){
try{
if(this.is_init){
this.is_songlist=true;
this.sp_listmethod=(this.sp_listmethod+1)%3;
if(this.dom_listouter&&this.dom_listorder){
switch(this.sp_listmethod){
case YOBO_SL_LOOP_BACK:
this.dom_listorder.className="ctrlback";
break;
case YOBO_SL_LOOP_RND:
this.dom_listorder.className="ctrlrnd";
break;
default:
this.dom_listorder.className="ctrlorder";
}
}
}
}
catch(e){
traceError("Error yobo_songPlayer::updateListMethod -> "+e);
}
},stopSong:function(_13){
try{
if(this.is_init){
clearTimeout(this.sp_loadtimer);
clearTimeout(this.sp_looptimer);
this.sp_status=YOBO_SP_STATUS_STOP;
try{
this.ext_flash.close();
}
catch(e){
traceError("Error yobo_songPlayer::stopSong(EXT) -> "+e);
}
if(this.dom_pagebtn){
this.dom_pagebtn.className="frameplay";
}
if(this.dom_songouter&&this.dom_songctrl&&this.dom_songtime&&this.dom_songtable){
this.dom_songctrl.className="ybscontrol";
this.dom_songtime.innerHTML="00:00";
this.dom_songtable.style.backgroundPosition=(this.dom_songtable.offsetWidth-614)+"px 0px";
}
if(this.dom_listouter&&this.dom_listplay&&this.is_songlist){
this.dom_listplay.className="ctrlplay";
}
this.dom_songouter=null;
this.dom_songctrl=null;
this.dom_songtable=null;
this.dom_songtime=null;
if(!_13){
if(this.is_songlist){
this.playNext();
}else{
this.loadSong(this.sp_songurl,this.sp_songid,this.sp_songrnd,this.is_upload);
}
}
}
}
catch(e){
traceError("Error yobo_songPlayer::stopSong -> "+e);
}
},playNext:function(){
try{
if(this.is_init){
if(this.getNextIndex(true)){
this.is_songlist=true;
var _14=this.sp_songlist[this.sp_listcuridx];
this.startSong(_14.url,_14.sid,_14.rnd,false,_14.isup);
}
}
}
catch(e){
traceError("Error yobo_songPlayer::playNext -> "+e);
}
},playPrev:function(){
try{
if(this.is_init){
if(this.getNextIndex(false)){
this.is_songlist=true;
var _15=this.sp_songlist[this.sp_listcuridx];
this.startSong(_15.url,_15.sid,_15.rnd,false,_15.isup);
}
}
}
catch(e){
traceError("Error yobo_songPlayer::playPrev -> "+e);
}
},startSong:function(url,sid,rnd,_19,_1a){
try{
if(this.is_init){
if(url==this.sp_songurl&&sid==this.sp_songid&&rnd==this.sp_songrnd){
switch(this.sp_status){
case YOBO_SP_STATUS_STOP:
this.loadSong(this.sp_songurl,this.sp_songid,this.sp_songrnd,this.is_upload);
break;
case YOBO_SP_STATUS_LOAD:
break;
case YOBO_SP_STATUS_PLAY:
this.pauseSong();
break;
case YOBO_SP_STATUS_PAUSE:
this.resumeSong();
break;
default:
traceError("Error yobo_songPlayer::playList -> unknown status: "+this.sp_status);
}
}else{
if(_19){
this.sp_listcuridx=this.getIndexInList(url,sid,rnd);
}
if(this.sp_status!=YOBO_SP_STATUS_STOP){
this.stopSong(true);
}
if(url==""||url=="-1"){
show_oninvaildsongurl(sid);
return false;
}else{
this.loadSong(url,sid,rnd,_1a);
}
}
}
}
catch(e){
traceError("Error yobo_songPlayer::startSong -> "+e);
}
},loadSong:function(url,sid,rnd,_1e){
try{
if(this.is_init){
clearTimeout(this.sp_loadtimer);
clearTimeout(this.sp_looptimer);
if(this.sp_status==YOBO_SP_STATUS_STOP){
this.sp_status=YOBO_SP_STATUS_LOAD;
if(this.win_flash){
try{
this.win_flash.PauseMP3();
}
catch(e){
traceError("Error yobo_songPlayer::loadSong(WIN) -> "+e);
}
}
this.dom_songouter=$("ybs"+sid+rnd);
this.dom_songctrl=$("ybs"+sid+rnd+"_ctrl");
this.dom_songtable=$("ybs"+sid+rnd);
this.dom_songtime=$("ybs"+sid+rnd+"_time");
if(this.dom_songouter&&this.dom_songctrl&&this.dom_songtable&&this.dom_songtime){
this.sp_songurl=url;
this.sp_songid=sid;
this.sp_songrnd=rnd;
this.is_upload=_1e;
this.dom_songctrl.className="ybscontrolpause";
if(this.dom_pagebtn&&this.is_pagebtn){
this.dom_pagebtn.className="framepause";
}
if(this.dom_listouter&&this.dom_listplay&&this.is_songlist){
this.dom_listplay.className="ctrlstop";
}
try{
this.ext_flash.start(this.sp_songurl);
}
catch(e){
traceError("Error yobo_songPlayer::loadSong(EXT) -> "+e);
}
var _1f=this;
this.sp_loadtimer=setTimeout(function(){
_1f.loadTimeout();
},30*1000);
this.sp_looptimer=setTimeout(function(){
_1f.loopSong();
},700);
show_loading(this.dom_songctrl);
try{
pageTracker._trackPageview("/ajax/song_bar/play");
}
catch(e){
}
}else{
this.removeFromList(url,sid,rnd);
this.stopSong(!this.is_songlist);
}
}
}
}
catch(e){
traceError("Error yobo_songPlayer::loadSong -> "+e);
}
},loadTimeout:function(){
try{
clearTimeout(this.sp_loadtimer);
clearTimeout(this.sp_looptimer);
if(this.sp_status==YOBO_SP_STATUS_STOP||this.sp_status==YOBO_SP_STATUS_LOAD){
printE({title:ERROR_GENERAL_MSG,li:[ERROR_LOADSONG_TIMEOUT],type:"alert",className:"error"});
this.stopSong(!this.is_songlist);
}
}
catch(e){
traceError("Error yobo_songPlayer::loadTimeout -> "+e);
}
},loopSong:function(){
try{
clearTimeout(this.sp_looptimer);
if(this.sp_status!=YOBO_SP_STATUS_STOP){
var dur=parseInt(this.ext_flash.getDur());
var pos=parseInt(this.ext_flash.getPosi());
var off=Math.floor((dur-pos)/1000);
if(off>1){
if(this.sp_status==YOBO_SP_STATUS_LOAD){
clearTimeout(this.sp_loadtimer);
this.sp_status=YOBO_SP_STATUS_PLAY;
hide_loading();
if(this.sp_songid!=-1&&!this.is_upload){
new Ajax.Request("/player/write_log?song_id="+this.sp_songid+"&flag=1",{method:"get",asynchronous:true,evalScripts:true});
}
}
var len=this.dom_songtable.offsetWidth*(pos/dur)-614;
this.dom_songtable.style.backgroundPosition=len+"px 0px";
var dm=(Math.floor(off/60)).toString();
var ds=(off%60).toString();
if(dm.length==1){
dm="0"+dm;
}
if(ds.length==1){
ds="0"+ds;
}
this.dom_songtime.innerHTML=dm+":"+ds;
}else{
if(this.sp_status!=YOBO_SP_STATUS_STOP&&this.sp_status!=YOBO_SP_STATUS_LOAD){
if(this.sp_songid!=-1&&!this.is_upload){
new Ajax.Request("/player/write_log?song_id="+this.sp_songid+"&flag=0",{method:"get",asynchronous:true,evalScripts:true});
try{
pageTracker._trackPageview("/ajax/song_bar/play_finish");
}
catch(e){
}
}
this.stopSong(false);
}
}
var _26=this;
this.sp_looptimer=setTimeout(function(){
_26.loopSong();
},700);
}
}
catch(e){
traceError("Error yobo_songPlayer::loopSong -> "+e);
}
},pauseSong:function(){
try{
if(this.is_init){
if(this.sp_status==YOBO_SP_STATUS_PLAY){
clearTimeout(this.sp_looptimer);
this.sp_status=YOBO_SP_STATUS_PAUSE;
try{
this.ext_flash.pause();
}
catch(e){
traceError("Error yobo_songPlayer::pauseSong(EXT) -> "+e);
}
if(this.dom_pagebtn&&this.is_pagebtn){
this.dom_pagebtn.className="frameplay";
}
if(this.dom_songouter&&this.dom_songctrl){
this.dom_songctrl.className="ybscontrolplay";
}
if(this.dom_listouter&&this.dom_listplay&&this.is_songlist){
this.dom_listplay.className="ctrlplay";
}
}
}
}
catch(e){
traceError("Error yobo_songPlayer::pauseSong -> "+e);
}
},resumeSong:function(){
try{
if(this.is_init){
if(this.sp_status==YOBO_SP_STATUS_PAUSE){
clearTimeout(this.sp_looptimer);
this.sp_status=YOBO_SP_STATUS_PLAY;
try{
this.ext_flash.resume();
}
catch(e){
traceError("Error yobo_songPlayer::resumeSong(EXT) -> "+e);
}
if(this.dom_pagebtn&&this.is_pagebtn){
this.dom_pagebtn.className="framepause";
}
if(this.dom_songouter&&this.dom_songctrl){
this.dom_songctrl.className="ybscontrolpause";
}
if(this.dom_listouter&&this.dom_listplay&&this.is_songlist){
this.dom_listplay.className="ctrlstop";
}
var _27=this;
this.sp_looptimer=setTimeout(function(){
_27.loopSong();
},700);
}
}
}
catch(e){
traceError("Error yobo_songPlayer::resumeSong -> "+e);
}
},getNextIndex:function(_28){
try{
if(this.sp_songlist&&this.sp_songlist.length>0){
switch(this.sp_listmethod){
case YOBO_SL_LOOP_BACK:
if(_28){
this.sp_listcuridx--;
}else{
this.sp_listcuridx++;
}
break;
case YOBO_SL_LOOP_RND:
this.sp_listcuridx=Math.floor(Math.random()*this.sp_songlist.length);
break;
default:
if(_28){
this.sp_listcuridx++;
}else{
this.sp_listcuridx--;
}
}
this.sp_listcuridx=(this.sp_listcuridx+this.sp_songlist.length)%this.sp_songlist.length;
return true;
}else{
return false;
}
}
catch(e){
traceError("Error yobo_songPlayer::getNextIndex -> "+e);
return false;
}
},getIndexInList:function(url,sid,rnd){
try{
if(this.sp_songlist&&this.sp_songlist.length>0){
for(var i=0;i<this.sp_songlist.length;i++){
var _2d=this.sp_songlist[i];
if(_2d.url==url&&_2d.sid==sid&&_2d.rnd==rnd){
return i;
}
}
}else{
return 0;
}
}
catch(e){
traceError("Error yobo_songPlayer::getIndexInList -> "+e);
return 0;
}
},removeFromList:function(url,sid,rnd){
try{
if(this.sp_songlist&&this.sp_songlist.length>0){
for(var i=0;i<this.sp_songlist.length;i++){
var _32=this.sp_songlist[i];
if(_32.url==url&&_32.sid==sid&&_32.rnd==rnd){
this.sp_listcuridx.splice(i,1);
if(this.sp_listcuridx>=i){
this.sp_listcuridx--;
}
return true;
}
}
}
return false;
}
catch(e){
traceError("Error yobo_songPlayer::getIndexInList -> "+e);
return false;
}
}};
}
var SONG_PLAYER_ITEM=new yobo_songPlayer();
function yobo_init_pageplayer(){
SONG_PLAYER_ITEM.initPlayer();
}
function yobo_play_song(u,s,r,f,iu){
try{
if(!yb_login){
show_logindlg("normal");
return false;
}
}
catch(e){
alert(e);
}
SONG_PLAYER_ITEM.playSong(u,s,r,f,iu);
try{
pageTracker._trackPageview("/ajax/song_bar/play");
}
catch(e){
}
}
function yobo_play_list(l){
SONG_PLAYER_ITEM.playList(l);
try{
pageTracker._trackPageview("/ajax/song_bar/play_list");
}
catch(e){
}
}
function yobo_init_list(l){
SONG_PLAYER_ITEM.initList(l);
}
function yobo_play_listprev(){
SONG_PLAYER_ITEM.playPrev();
try{
pageTracker._trackPageview("/ajax/song_bar/prev_song");
}
catch(e){
}
}
function yobo_play_listnext(){
SONG_PLAYER_ITEM.playNext();
try{
pageTracker._trackPageview("/ajax/song_bar/next_song");
}
catch(e){
}
}
function yobo_update_listmethod(){
SONG_PLAYER_ITEM.updateListMethod();
}
function yobo_flashcallback_play(){
SONG_PLAYER_ITEM.stopSong(true);
}
function yobo_play_stop(){
SONG_PLAYER_ITEM.stopSong(true);
}
if(typeof (yobo_songPlayerLite)!="function"){
var yobo_songPlayerLite=Class.create();
yobo_songPlayerLite.prototype={initialize:function(){
try{
this.flash=null;
this.status=0;
this.url=null;
this.songid=null;
this.randnum=null;
this.controls=null;
this.songlink=null;
this.is_init=false;
}
catch(e){
traceError("Error yobo_songPlayerLite::initialize -> "+e);
return false;
}
},initPlayer:function(){
try{
this.flash=window["pagesongplayer"]?window["pagesongplayer"]:document["pagesongplayer"];
this.status=0;
this.url=null;
this.songid=null;
this.randnum=null;
this.controls=null;
this.songlink=null;
this.is_init=true;
}
catch(e){
traceError("Error yobo_songPlayerLite::initPlayer -> "+e);
return false;
}
},play:function(url,sid,rnd,_3d,_3e){
try{
if(this.is_init){
if(this.url==url&&this.songid==sid&&this.randnum==rnd){
switch(this.status){
case 0:
this.loadSong(url,sid,rnd,_3d,_3e);
break;
case 1:
break;
case 2:
this.pause();
break;
case 3:
this.resume();
break;
default:
alert(ERROR_BAD_STATUS+this.status);
}
}else{
if(this.status>0){
this.controls.innerHTML="Play";
this.stopAll();
}
if(url==""||url=="-1"){
show_oninvaildsongurl(sid);
return false;
}else{
this.loadSong(url,sid,rnd,_3d,_3e);
}
}
}
}
catch(e){
traceError("Error yobo_songPlayerLite::play -> "+e);
return false;
}
},loadSong:function(url,sid,rnd,_42,_43){
try{
if(this.is_init){
this.status=1;
clearTimeout(this.loadtimer);
clearTimeout(this.looptimer);
this.url=url;
this.songid=sid;
this.randnum=rnd;
this.controls=$(_42);
this.songlink=$(_43);
this.controls.innerHTML="<img src=\"/images/icons/songbar_pause.gif\" align=\"absmiddle\" />";
this.songurl=url;
var _44=this;
setTimeout(function(){
_44.flash.start(_44.songurl);
},0);
this.loadtimer=setTimeout(function(){
clearTimeout(this.loadtimer);
clearTimeout(this.looptimer);
if(_44.status<2){
_44.controls.innerHTML="Play";
printE({title:ERROR_GENERAL_MSG,li:[ERROR_LOADSONG_TIMEOUT],type:"alert",className:"error"});
_44.stopAll();
}
},1000*30);
this.looptimer=setTimeout(function(){
_44.loop();
},100);
show_loading(this.controls);
if(this.songid!=-1){
new Ajax.Request("/player/write_log?song_id="+this.songid+"&flag=1",{method:"get",asynchronous:true,evalScripts:true});
}
}
}
catch(e){
traceError("Error yobo_songPlayerLite::loadSong -> "+e);
return false;
}
},stop:function(){
try{
if(this.is_init){
this.status=0;
clearTimeout(this.loadtimer);
clearTimeout(this.looptimer);
var _45=this;
setTimeout(function(){
_45.flash.close();
},0);
this.loadSong(this.url,this.songid,this.randnum,this.controls,this.songlink);
}
}
catch(e){
traceError("Error yobo_songPlayerLite::stop -> "+e);
return false;
}
},loop:function(){
try{
clearTimeout(this.looptimer);
if(this.status>0&&this.status<3){
var dur=Math.floor(parseInt(this.flash.getDur())/1000);
var pos=Math.floor(parseInt(this.flash.getPosi())/1000);
var off=dur-pos;
if(off>0){
if(this.status==1){
clearTimeout(this.loadtimer);
this.status=2;
hide_loading();
}
var len=this.songlink.offsetWidth*(pos/dur)-614;
this.songlink.style.background="url(/images/progressbar.gif) "+len+"px center no-repeat";
}else{
if(this.status>1){
if(this.songid!=-1){
new Ajax.Request("/player/write_log?song_id="+this.songid+"&flag=0",{method:"get",asynchronous:true,evalScripts:true});
}
this.controls.innerHTML="Play";
this.stop();
}
}
var _4a=this;
this.looptimer=setTimeout(function(){
_4a.loop();
},200);
}
}
catch(e){
traceError("Error yobo_songPlayerLite::loop -> "+e);
return false;
}
},pause:function(){
try{
if(this.is_init){
if(this.status==2){
clearTimeout(this.looptimer);
this.status=3;
this.controls.innerHTML="<img src=\"/images/icons/songbar_play.gif\" align=\"absmiddle\" />";
var _4b=this;
setTimeout(function(){
_4b.flash.pause();
},0);
}
}
}
catch(e){
traceError("Error yobo_songPlayerLite::pause -> "+e);
return false;
}
},resume:function(){
try{
if(this.is_init){
if(this.status==3){
clearTimeout(this.looptimer);
this.status=2;
this.controls.innerHTML="<img src=\"/images/icons/songbar_pause.gif\" align=\"absmiddle\" />";
var _4c=this;
setTimeout(function(){
_4c.flash.resume();
},0);
this.looptimer=setTimeout(function(){
_4c.loop();
},200);
}
}
}
catch(e){
traceError("Error yobo_songPlayerLite::resume -> "+e);
return false;
}
},stopAll:function(){
try{
if(this.is_init){
this.status=0;
clearTimeout(this.loadtimer);
clearTimeout(this.looptimer);
if(this.songlink&&this.controls){
this.songlink.style.background="url(/images/progressbar.gif) "+(this.songlink.offsetWidth-614)+"px center no-repeat";
}
var _4d=this;
setTimeout(function(){
_4d.flash.close();
},0);
this.url=null;
this.songid=null;
this.randnum=null;
this.controls=null;
this.songlink=null;
}
}
catch(e){
traceError("Error yobo_songPlayerLite::stopAll -> "+e);
return false;
}
}};
}
var SONG_PLAYER_LITE=new yobo_songPlayerLite();
function yobo_init_liteplayer(){
SONG_PLAYER_LITE.initPlayer();
}
function yobo_play_lite(u,s,r,c,b){
SONG_PLAYER_LITE.play(u,s,r,c,b);
}
