jmaki.namespace("jmaki.widgets.moa.moaflashplayer");jmaki.widgets.moa.moaflashplayer.Widget=function(wargs){var _widget=this;var uuid="#"+wargs.uuid;var publish="/moa/moaflashplayer";var subscribe=["/moa/moaflashplayer"];var cloudContextRoot_replacethis="/";var tasks=["/playerTopic","/loadImage","/setTitle","/LandingPagePlayerTopic","/HomeSitePlayer","/loadHomesiteImage","/startGenericSignupPlayer","/loadPlayerDefaultImage"];var swfObj=cloudContextRoot+"resources/moa/moaflashplayer/MOAPlayer.swf";var width=570;var height=374;var previmagelist="";if(wargs.publish){publish=wargs.publish;}var playlistId="";if(wargs.subscribe){if(typeof wargs.subscribe=="string"){subscribe=[];subscribe.push(wargs.subscribe);}else{subscribe=wargs.subscribe;}}var initSubscribe=function(){_widget.subs=[];doSubscribe(subscribe+tasks[0],_widget.playerTopic);doSubscribe(subscribe+tasks[1],_widget.loadImage);doSubscribe(subscribe+tasks[2],_widget.setTitle);doSubscribe(subscribe+tasks[3],_widget.LandingPagePlayerTopic);doSubscribe(subscribe+tasks[4],_widget.HomeSitePlayer);doSubscribe(subscribe+tasks[5],_widget.loadHomesiteImage);doSubscribe(subscribe+tasks[6],_widget.startGenericSignupPlayer);doSubscribe(subscribe+tasks[7],_widget.loadPlayerDefaultImage);};var doSubscribe=function(topic,handler){var i=jmaki.subscribe(topic,handler);_widget.subs.push(i);};var initPlayer=function(){var flashvars={};var params={};var swfObj=cloudContextRoot+"resources/moa/moaflashplayer/MOAPlayer.swf";var width=570;var height=374;var flashAttribId="EIFace";if(wargs.args.swfObj){swfObj=cloudContextRoot+wargs.args.swfObj;if(wargs.args.height){height=wargs.args.height;}if(wargs.args.width){width=wargs.args.width;}}else{if(!switchToRed5){swfObj=cloudContextRoot+"resources/moa/moaflashplayer/MOAWowzaPlayer.swf";}}if(wargs.args.flashAttribId){flashAttribId=wargs.args.flashAttribId;}params.allowFullScreen="true";params.allowscriptaccess="always";params.allownetworking="all";params.wmode="transparent";var attributes={};attributes.id=flashAttribId;swfobject.embedSWF(swfObj,"swf",width,height,"9.0.0",false,flashvars,params,attributes);};var playerLoadedCallBack=function(){};this.postLoad=function(){init();};var vidPath="";var actn="";this.playerTopic=function(e,c){if(e.message){this.vidPath=""+e.message;}if(e.action){this.actn=""+e.action;}startPlay(this.vidPath,this.actn);};this.playerTopicSlider=function(e,c){if(e.message){this.vidPath=""+e.message;}if(e.action){this.actn=""+e.action;}startPlaySlider(this.vidPath,this.actn);};this.LandingPagePlayerTopic=function(e,c){if(e.message){this.vidPath=""+e.message;}if(e.action){this.actn=""+e.action;}startLandingPagePlay(this.vidPath,this.actn);};this.HomeSitePlayer=function(e,c){if(e.message){this.vidPath=""+e.message;}if(e.action){this.actn=""+e.action;}startHomeSitePlayerPlay(this.vidPath,this.actn);};this.startGenericSignupPlayer=function(e,c){if(e.message){this.vidPath=""+e.message;}if(e.action){this.actn=""+e.action;}startGenericPlay("genericSignupPlayer",this.vidPath,this.actn);};this.loadPlayerDefaultImage=function(e,c){loadPlayerDefaultImageFunc(e.message);};this.loadImage=function(e,c){this.albumId="";this.playlistId="";this.trackId="";if(e.albumId){this.albumId=e.albumId;}if(e.playlistId){this.playlistId=e.playlistId;}if(e.trackId){this.trackId=e.trackId;}mediaImage.getPlayerImage(this.albumId,this.playlistId,this.trackId,null,null,MEDIA_TYPE_PLAYLIST_PLAYER_IMAGE,loadPlayerImage);};this.loadHomesiteImage=function(e,c){this.albumId="";this.playlistId="";this.trackId="";if(e.albumId){this.albumId=e.albumId;}if(e.playlistId){this.playlistId=e.playlistId;}if(e.trackId){this.trackId=e.trackId;}mediaImage.getPlayerImage(this.albumId,this.playlistId,this.trackId,null,null,MEDIA_TYPE_PLAYLIST_PLAYER_IMAGE,loadHomesitePlayerImage);};var init=function(){initSubscribe();initPlayer();};var startPlay=function(vidPath,action){if(!switchToRed5){fedoraRepo.getStreamInfoForPlayer(vidPath,action,doInit);}else{doInit(vidPath+action);}};var startLandingPagePlay=function(vidPath,action){if(!switchToRed5){fedoraRepo.getStreamInfoForPlayer(vidPath,action,doInit1);}else{doInit1(vidPath+action);}};var startPlaySlider=function(vidPath,action){if(!switchToRed5){fedoraRepo.getStreamInfoForPlayer(vidPath,action,doInit2);}else{doInit2(vidPath+action);}};var startHomeSitePlayerPlay=function(vidPath,action){if(!switchToRed5){fedoraRepo.getStreamInfoForPlayer(vidPath,action,doInit3);}else{doInit3(vidPath+action);}};var startGenericPlay=function(playerName,vidPath,action){if(!switchToRed5){fedoraRepo.getStreamInfoForPlayer(vidPath,action,doInitGenericSignupPlayer);}else{doInitGenericSignupPlayer(vidPath+action,playerName);}};var doInit=function(_sPath){start("EIFace","rtmp://www.musiconlinealive.com:9280/moastream",_sPath);};var doInit1=function(_sPath){start("LandingPagePlayer","rtmp://www.musiconlinealive.com:9280/moastream",_sPath);};var doInit2=function(_sPath){start("EIFaceSlider","rtmp://www.musiconlinealive.com:9280/moastream",_sPath);};var doInit3=function(_sPath){start("HomeSitePlayer","rtmp://www.musiconlinealive.com:9280/moastream",_sPath);};var doInitGenericSignupPlayer=function(_sPath,playerName){if(playerName==null){playerName="genericSignupPlayer";}start(playerName,"rtmp://www.musiconlinealive.com:9280/moastream",_sPath);};function flashMovie(movieName){if(window.document[movieName]){return window.document[movieName];}else{return document.getElementById(movieName);}}var start=function(_playerInstance,_connParam,_sPath){try{if(_sPath.indexOf("1msc23")!=-1){_sPath=_sPath.replace("||mp3:","||");_connParam="rtmp://fcdn2.flwint.net/201281";}flashMovie(_playerInstance).rcvConnectionParam(_connParam);if(cloudContextRoot!=null&&cloudContextRoot.substring(11,0).toLowerCase()=="http://cdn."){flashMovie(_playerInstance).rcvMediaParams(_sPath);}else{flashMovie(_playerInstance).rcvMediaParams(_sPath);}}catch(eror){}};var loadPlayerImage=function(imagesList){try{if(imagesList!=null&&imagesList.length>0){if(this.trackId>0&&comparevalue(imagesList,previmagelist)||this.trackId==""){flashMovie("EIFace").setPlayerImg(imagesList[0].httpUrl);}previmagelist=imagesList;}else{loadPlayerDefaultImageFunc(fullHttpUrl+"/images/"+page_name+"_default.jpg");}}catch(eror){}};var loadPlayerDefaultImageFunc=function(httpUrl){try{flashMovie("EIFace").setPlayerImg(httpUrl);}catch(eror){}};var loadHomesitePlayerImage=function(imagesList){try{if(imagesList!=null&&imagesList.length>0){if(this.trackId>0&&comparevalue(imagesList,previmagelist)||this.trackId==""){flashMovie("HomeSitePlayer").setPlayerImg(imagesList[0].httpUrl);}previmagelist=imagesList;}else{flashMovie("HomeSitePlayer").setPlayerImg("");}}catch(eror){}};function comparevalue(newobj,oldobj){var same=false;if(newobj==""||oldobj==""){return true;}for(var i in newobj){if(newobj[i].httpUrl!=oldobj[i].httpUrl){same=true;break;}}return same;}var sendTrackTitle=function(trackTitle){try{flashMovie("EIFace").rcvTrackTitle(trackTitle);}catch(eror){}};this.setTitle=function(e,c){if(e.from&&e.from=="backSliderPlayer"&&e.trackTitle){try{flashMovie("EIFaceSlider").rcvTrackTitle(e.trackTitle);}catch(eror){}}else{if(e.trackTitle){try{flashMovie("EIFace").rcvTrackTitle(e.trackTitle);}catch(eror){}}}};};
