1
0
mirror of https://github.com/danog/danuntu.git synced 2024-11-26 20:04:49 +01:00
danuntu/index_htm_files/magix_player.js

8 lines
48 KiB
JavaScript
Raw Permalink Normal View History

2022-04-03 22:25:51 +02:00
/**magix_player**/
var magixAudioVideoPlayer=null;function clog(obj){return ;if(navigator.userAgent.toLowerCase().indexOf("msie")==-1){console.log(obj)}else{if($("#mlog").length<=0){$("body").append("<div id='mlog' style='position:absolute;top:0;left:0;z-index:100000;background:#fff;color:#000;padding:10px;border:solid 1px red;'></div>")}$("#mlog").append(obj+"<br />")}}function MagixBase(){this.throwError=throwError;this.checkBrowser=checkBrowser;this.isNumber=isNumber;this.base=base;this.base();function base(){this.gl_isIE=this.checkBrowser("MSIE")}function throwError(func,err){clog("Error in "+func+": ");clog(err);return false}function checkBrowser(name){var agent=navigator.userAgent.toLowerCase();if(agent.indexOf(name.toLowerCase())>-1){return true}return false}function isNumber(n){return !isNaN(parseFloat(n))&&isFinite(n)}}function MagixPlayer(){this.base=MagixBase;this.base();this.flashMovie=false;this.flashAudioMovie=false;this.flashVideoMovie=false;this.flashEnabled=false;this.playerContainer=null;this.loaderContainer=null;this.contentContainer=null;this.controlContainer=null;this.errorContainer=null;this.errorhoverContainer=null;this.flashContainer=null;this.htmlContainer=null;this.playlist=[];this.showPlaylist=true;this.orderList=[];this.orderReference=[];this.plIndex=0;this.actIndex=-1;this.nav=null;this.mediaElem=null;this.playlistElem=null;this.btnPlayElem=null;this.btnStopElem=null;this.btnPauseElem=null;this.btnNextElem=null;this.btnPrevElem=null;this.btnLoopElem=null;this.btnLoopActiveElem=null;this.btnShuffleElem=null;this.btnShuffleActiveElem=null;this.btnFullscreenElem=null;this.bntMuteElem=null;this.bntUnmuteElem=null;this.bntVolumeMaxElem=null;this.bntVolumeBarElem=null;this.btnVolumeValElem=null;this.fieldCurTimeElem=null;this.fieldDurationElem=null;this.btnTimeBarElem=null;this.btnTimeValElem=null;this.properties={};this.swfData={};this.showVideo="auto";this.playFlash=false;this.paused=true;this.lastMediaVolume=0.8;this.duration=0;this.curTime=0;this.screen={width:"400",height:"400"};this.order="flash";this.isStarted=false;this.propertiesSet=false;this.keysActivated=false;this.init=init;this.start=start;this.destroy=destroy;this.setCssSelectors=setCssSelectors;this.setProperties=setProperties;this.setPlaylist=setPlaylist;this.playMedia=playMedia;this.playNext=playNext;this.stopMedia=stopMedia;this.unloadMedia=unloadMedia;this.loadMedia=loadMedia;this.loadFlash=loadFlash;this.loadHTML=loadHTML;this.prepareHTML=prepareHTML;this.checkMediaType=checkMediaType;this.setMediaVolume=setMediaVolume;this.setMediaVolumeBar=setMediaVolumeBar;this.startTimer=startTimer;this.setTimer=setTimer;this.setCurTime=setCurTime;this.activateKeys=activateKeys;this.deactivateKeys=deactivateKeys;this.loopMedia=loopMedia;this.shufflePlaylist=shufflePlaylist;this.fullscreenMedia=fullscreenMedia;this.fnFallback=fnFallback;this.loadDefaultFlash=loadDefaultFlash;this.setDuration=setDuration;this.getTimeVal=getTimeVal;this.trackEnded=trackEnded;this.setPropertyCookie=setPropertyCookie;this.getPropertyCookie=getPropertyCookie;this.checkFlashPlugin=checkFlashPlugin;this.buildSWF=buildSWF;this.getTimer=getTimer;this.stopTimer=stopTimer;this.showError=showError;this.hideError=hideError;function init(properties){this.nav=navigator;this.flashEnabled=this.checkFlashPlugin();this.properties=properties;if(this.setCssSelectors()){var zIndex=this.playerContainer.css("z-index");this.contentContainer.css({opacity:0});this.errorContainer.hide();this.errorhoverContainer.hide();var cData=this.getPropertyCookie();if(cData){if(cData.volume>0){this.properties.volume=cData.volume}if(this.properties.playLoop=="auto"||this.properties.playLoop==undefined){this.properties.playLoop=cData.loop}}if(this.btnPauseElem!=null){this.btnPauseElem.hide()}if(this.btnUnmuteElem!=null){this.btnUnmuteElem.hide()}this.loadDefaultFlash()}else{alert("Error: Unable to open player")}}function start(){if(!this.isStarted){this.isStarted=true;this.videoContainer.css({opacity:"0",height:"1px",overflow:"hidden"});$(this.contentContainer).show();this.setProperties();this.screen={width:$(window).
/**skin**/
function openMagixPlayer(params){if(params.skinType==null||params.skinType==undefined){params.skinType="small"}return new MagixPlayer_Skin(params)}function MagixPlayer_SkinBase(){this.mod={};this.dom={};this.mpProps={};this.magixPlayer=null;this.init=init;this.setParameters=setParameters;this.buildMagixPlayer=buildMagixPlayer;this.defineHTMLmoduls=defineHTMLmoduls;this.defineDOMobjects=defineDOMobjects;this.completeLoading=completeLoading;this.startLoading=startLoading;this.calculatePlaylist=calculatePlaylist;this.setDefaultPlaylistCss=setDefaultPlaylistCss;this.setDefaultErrorCss=setDefaultErrorCss;this.completeStructure=completeStructure;function init(params){this.setParameters(params);this.defineHTMLmoduls();this.buildHTMLstructure();this.startLoading();this.setCss();this.buildMagixPlayer();this.container.append("<style type='text/css'>"+this.skinStyles+"</style>")}function setParameters(params){var obj=this;var mpPropVals={skinType:"small",skinColor:"dark",container:$("body"),pre:"mx",path:"",playlist:[],plMaxHeight:"auto",plFixHeight:"auto",showPlaylist:true,errorTxt:"",errorfatalHoverTxt:"File not supported by your browser",errorlocalTxt:"",errorHoverTxt:"The MAGIX MP3 Player doesn&lsquo;t work in this browser version when viewing locally exported pages. Once your website is published online the player will work in this and in all popular web browsers. <span class='el_link'>[close]</span>",errorPluginHoverTxt:"To use the magix player please install the latest Adobe Flash-Player",errorPluginIOSHoverTxt:"To use the magix player please install the latest Adobe Flash-Player or Quicktime",cssSelectors:{}};$.each(mpPropVals,function(k,v){obj[k]=(params[k]===null||params[k]==undefined)?v:params[k]});this.pre="mxw3mp-"+this.pre;this.skinPath=this.path;this.spritePath=this.path+"sprite.png";this.loaderPath=this.path+"loader.gif";this.attentionPath=this.path+"attention.png";mpPropVals={order:"flash",fileType:"auto",fn:{},showTimer:true,playLoop:true,autoplay:true,activateKeys:true,defaultVol:0.7,flashLocal:false,flashWidth:100,flashHeight:100,flashAllowFullScreen:true};$.each(mpPropVals,function(k,v){obj.mpProps[k]=(params[k]===null||params[k]==undefined)?v:params[k]})}function defineHTMLmoduls(){this.mod.loader=$("<div id='"+this.pre+"-loader'></div>");this.mod.videoPane=$("<div id='"+this.pre+"-videoPane'></div>");this.mod.content=$("<div id='"+this.pre+"-content'></div>");this.mod.errorPane=$("<div id='"+this.pre+"-errorPane'><div id='"+this.pre+"-errorPaneInner'><div id='"+this.pre+"-errorPaneAttention'></div>"+this.errorTxt+"</div></div>");this.mod.errorhoverPane=$("<div id='"+this.pre+"-errorhoverPane'><div class='errorhoverShort'>"+this.errorlocalTxt+"</div></div>");this.mod.errorHover=$("<div id='"+this.pre+"-errorHover' class='errorHover'>"+this.errorHoverTxt+"</div>");this.mod.errorhoverPane.append(this.mod.errorHover);this.mod.controler=$("<div id='"+this.pre+"-controler'></div>");this.mod.flash=$("<div><div id='"+this.pre+"-flash'></div></div>");this.mod.html=$("<div id='"+this.pre+"-html'></div>");this.mod.btnPlay=$("<div id='"+this.pre+"-play' class='knob "+this.pre+"-btnPlay'></div>");this.mod.btnPause=$("<div id='"+this.pre+"-pause' class='knob "+this.pre+"-btnPause'></div>");this.mod.btnMute=$("<div id='"+this.pre+"-mute' class='knob "+this.pre+"-btnMute'></div>");this.mod.btnUnmute=$("<div id='"+this.pre+"-unmute' class='knob "+this.pre+"-btnUnmute'></div>");this.mod.dspCurTime=$("<span id='"+this.pre+"-curTime'></span>");this.mod.dspDuration=$("<span id='"+this.pre+"-duration'></span>");this.mod.dspTimeBar=$("<div id='"+this.pre+"-timeBar'><div id='"+this.pre+"-timeVal'></div></div>");this.mod.display=$("<div id='"+this.pre+"-display'></div>");this.mod.dspTimer=$("<div id='"+this.pre+"-timer'></div>");this.mod.volumeBar=$("<div id='"+this.pre+"-volume'><div id='"+this.pre+"-volumeBar'><div id='"+this.pre+"-volumeVal'></div></div></div>");this.mod.playlistPane=$("<div id='"+this.pre+"-playlistPane'></div>");this.mod.playlist=$("<div id='"+this.pre+"-playlist'></div>");this.mod.playlistTrack=$("<div id='"+t
/**theme**/
function MagixPlayer_Skin(params){this.parent=MagixPlayer_Skin.prototype;this.init=init;this.buildHTMLstructure=buildHTMLstructure;this.loadPLScrollParams=loadPLScrollParams;this.setCss=setCss;this.init(params);function init(params){params.skinType="flat";this.parent.init.call(this,params)}function buildHTMLstructure(){this.mod.dspCurTime.html("0:00");this.mod.dspDuration.html("0:00");this.mod.dspTimer.append(this.mod.dspCurTime);this.mod.dspTimer.append("/");this.mod.dspTimer.append(this.mod.dspDuration);this.mod.controler.append(this.mod.btnPlay);this.mod.controler.append(this.mod.btnPause);this.mod.controler.append(this.mod.dspTimeBar);this.mod.controler.append(this.mod.dspTimer);this.mod.controler.append(this.mod.btnMute);this.mod.controler.append(this.mod.btnUnmute);this.mod.controler.append(this.mod.volumeBar);this.mod.content.append(this.mod.controler);this.completeStructure();this.defineDOMobjects(["loader","content","controler","play","pause","mute","unmute","curTime","duration","timeBar","timeVal","timer","volumeBar","volumeVal"]);this.calculatePlaylist(18,20)}function loadPLScrollParams(){if(this.showPlaylist){return{pre:this.pre,pane:this.dom.playlistPane,scrollcontent:this.dom.playlist,height:this.container.height()-20,width:182,scrollerCSS:{background:"#222",width:"5px"},scrollbarCSS:{background:"#777",width:"5px"}}}else{return{}}}function setCss(){this.mpPropsSkinWidth=185;this.mpPropsSkinHeight=18;this.dom.loader.css({width:this.mpPropsSkinWidth+"px",height:"60px",background:"url('"+this.loaderPath+"') center center no-repeat"});var cwidth=(this.mpProps.flashWidth>this.mpPropsSkinWidth)?this.mpProps.flashWidth:this.mpPropsSkinWidth;this.container.css({width:cwidth+"px"});this.dom.controler.css({width:this.mpPropsSkinWidth+"px",height:this.mpPropsSkinHeight+"px",overflow:"hidden",background:"url('"+this.spritePath+"') 0 -1px no-repeat",margin:"0 auto 1px auto"});this.dom.controler.find(".knob").css({width:"13px",height:"12px","float":"left","margin-top":"4px","margin-bottom":"3px","margin-left":"0px","margin-right":"0px",cursor:"pointer"});this.dom.timeBar.css({"float":"left",width:"54px",height:"5px",margin:"5px 0 0 2px",padding:"2px 0",cursor:"pointer"});this.dom.timeVal.css({width:"1px",height:"4px",background:"url('"+this.spritePath+"') -60px -24px no-repeat",margin:"0",width:"0"});this.dom.timer.css({"font-size":"9px",color:"#eee","float":"left",margin:"4px 4px 0 5px"});this.dom.play.css({"margin-left":"7px"});this.dom.pause.css({"margin-left":"7px",display:"none"});this.dom.mute.css({"margin-left":"7px"});this.dom.unmute.css({"margin-left":"7px",display:"none"});this.dom.volumeBar.css({"float":"left",width:"30px",height:"4px",padding:"5px 0 0 0",margin:"2px 0 0 3px",cursor:"pointer"});this.dom.volumeVal.css({width:"20px",height:"4px",background:"url('"+this.spritePath+"') -117px -24px no-repeat",margin:"0",padding:"0"});this.dom.videoPane.css({background:"#efefef",margin:"0px 0 5px 0",border:"solid 1px #999"});this.dom.html.find("video").css({margin:"auto"});this.mod.playlistPane.css({clear:"both"});this.setDefaultPlaylistCss();this.setDefaultErrorCss();this.skinStyles+=" ."+this.pre+"-btnPlay{background:url('"+this.spritePath+"') -1px -24px no-repeat;}";this.skinStyles+=" ."+this.pre+"-btnPlayHover{background:url('"+this.spritePath+"') -1px -38px no-repeat;}";this.skinStyles+=" ."+this.pre+"-btnPause{background:url('"+this.spritePath+"') -15px -24px no-repeat;}";this.skinStyles+=" ."+this.pre+"-btnPauseHover{background:url('"+this.spritePath+"') -15px -38px no-repeat;}";this.skinStyles+=" ."+this.pre+"-btnMute{background:url('"+this.spritePath+"') -32px -24px no-repeat;}";this.skinStyles+=" ."+this.pre+"-btnMuteHover{background:url('"+this.spritePath+"') -32px -38px no-repeat;}";this.skinStyles+=" ."+this.pre+"-btnUnmute{background:url('"+this.spritePath+"') -46px -24px no-repeat;}";this.skinStyles+=" ."+this.pre+"-btnUnmuteHover{background:url('"+this.spritePath+"') -46px -38px no-repeat;}";this.skinStyles+=" #"+this.pre+"-html video{display:block;margin:0 auto}";if((this.gl_isIE)){this.dom.volume