From 384bc7afc86be706bf61def09afc8306cdad2443 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sat, 2 Mar 2013 23:56:13 +0100 Subject: #2033 - Add Flowplayer 5 to play HTML5 videos. - add Flowplayer 5 to lib/flowplayer-html5 - move existing Flash Flowplayer to lib/flowplayer-flash - update page.html.php and movieplayer.html.php --HG-- rename : lib/flowplayer.controls.swf => lib/flowplayer-flash/flowplayer.controls.swf rename : lib/flowplayer.js => lib/flowplayer-flash/flowplayer.js rename : lib/flowplayer.pseudostreaming-byterange.swf => lib/flowplayer-flash/flowplayer.pseudostreaming-byterange.swf rename : lib/flowplayer.pseudostreaming.swf => lib/flowplayer-flash/flowplayer.pseudostreaming.swf rename : lib/flowplayer.swf => lib/flowplayer-flash/flowplayer.swf --- lib/flowplayer.js | 228 ------------------------------------------------------ 1 file changed, 228 deletions(-) delete mode 100644 lib/flowplayer.js (limited to 'lib/flowplayer.js') diff --git a/lib/flowplayer.js b/lib/flowplayer.js deleted file mode 100644 index 83cd974f..00000000 --- a/lib/flowplayer.js +++ /dev/null @@ -1,228 +0,0 @@ -!function(){function log(args){console.log("$f.fireEvent",[].slice.call(args));} -function clone(obj){if(!obj||typeof obj!='object'){return obj;} -var temp=new obj.constructor();for(var key in obj){if(obj.hasOwnProperty(key)){temp[key]=clone(obj[key]);}} -return temp;} -function each(obj,fn){if(!obj){return;} -var name,i=0,length=obj.length;if(length===undefined){for(name in obj){if(fn.call(obj[name],name,obj[name])===false){break;}}}else{for(var value=obj[0];i1){var params=arguments[1],conf=(arguments.length==3)?arguments[2]:{};if(typeof params=='string'){params={src:params};} -params=extend({bgcolor:"#000000",version:[10,1],expressInstall:"http://releases.flowplayer.org/swf/expressinstall.swf",cachebusting:false},params);if(typeof arg=='string'){if(arg.indexOf(".")!=-1){var instances=[];each(select(arg),function(){instances.push(new Player(this,clone(params),clone(conf)));});return new Iterator(instances);}else{var node=el(arg);return new Player(node!==null?node:clone(arg),clone(params),clone(conf));}}else if(arg){return new Player(arg,clone(params),clone(conf));}} -return null;};extend(window.$f,{fireEvent:function(){var a=[].slice.call(arguments);var p=$f(a[0]);return p?p._fireEvent(a.slice(1)):null;},addPlugin:function(name,fn){Player.prototype[name]=fn;return $f;},each:each,extend:extend});if(typeof jQuery=='function'){jQuery.fn.flowplayer=function(params,conf){if(!arguments.length||typeof arguments[0]=='number'){var arr=[];this.each(function(){var p=$f(this);if(p){arr.push(p);}});return arguments.length?arr[arguments[0]]:new Iterator(arr);} -return this.each(function(){$f(this,clone(params),conf?clone(conf):{});});};}}();!function(){var IE=document.all,URL='http://get.adobe.com/flashplayer',JQUERY=typeof jQuery=='function',RE=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,GLOBAL_OPTS={width:'100%',height:'100%',id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:'always',quality:'high',version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};});} -function extend(to,from){if(from){for(var key in from){if(from.hasOwnProperty(key)){to[key]=from[key];}}} -return to;} -function map(arr,func){var newArr=[];for(var i in arr){if(arr.hasOwnProperty(i)){newArr[i]=func(arr[i]);}} -return newArr;} -window.flashembed=function(root,opts,conf){if(typeof root=='string'){root=document.getElementById(root.replace("#",""));} -if(!root){return;} -if(typeof opts=='string'){opts={src:opts};} -return new Flash(root,extend(extend({},GLOBAL_OPTS),opts),conf);};var f=extend(window.flashembed,{conf:GLOBAL_OPTS,getVersion:function(){var fo,ver;try{ver=navigator.plugins["Shockwave Flash"].description.slice(16);}catch(e){try{fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");ver=fo&&fo.GetVariable("$version");}catch(err){try{fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");ver=fo&&fo.GetVariable("$version");}catch(err2){}}} -ver=RE.exec(ver);return ver?[1*ver[1],1*ver[(ver[1]*1>9?2:3)]*1]:[0,0];},asString:function(obj){if(obj===null||obj===undefined){return null;} -var type=typeof obj;if(type=='object'&&obj.push){type='array';} -switch(type){case'string':return string2JsonString(obj);case'array':return'['+map(obj,function(el){return f.asString(el);}).join(',')+']';case'function':return'"function()"';case'object':var str=[];for(var prop in obj){if(obj.hasOwnProperty(prop)){str.push('"'+prop+'":'+f.asString(obj[prop]));}} -return'{'+str.join(',')+'}';} -return String(obj).replace(/\s/g," ").replace(/\'/g,"\"");},getHTML:function(opts,conf){opts=extend({},opts);var html='';} -opts.width=opts.height=opts.id=opts.w3c=opts.src=null;opts.onFail=opts.version=opts.expressInstall=null;for(var key in opts){if(opts[key]){html+='';}} -var vars="";if(conf){for(var k in conf){if(conf[k]){var val=conf[k];vars+=encodeURIComponent(k)+'=' -+encodeURIComponent(/function|object/.test(typeof val)?f.asString(val):val) -+'&';}} -vars=vars.slice(0,-1);html+='';} -html+="";return html;},isSupported:function(ver){return VERSION[0]>ver[0]||VERSION[0]==ver[0]&&VERSION[1]>=ver[1];}});var VERSION=f.getVersion();function Flash(root,opts,conf){if(f.isSupported(opts.version)){root.innerHTML=f.getHTML(opts,conf);}else if(opts.expressInstall&&f.isSupported([6,65])){root.innerHTML=f.getHTML(extend(opts,{src:opts.expressInstall}),{MMredirectURL:encodeURIComponent(location.href),MMplayerType:'PlugIn',MMdoctitle:document.title});}else{if(!root.innerHTML.replace(/\s/g,'')){root.innerHTML="

Flash version "+opts.version+" or greater is required

"+"

"+ -(VERSION[0]>0?"Your version is "+VERSION:"You have no flash plugin installed")+"

"+ -(root.tagName=='A'?"

Click here to download latest version

":"

Download latest version from here

");if(root.tagName=='A'||root.tagName=="DIV"){root.onclick=function(){location.href=URL;};}} -if(opts.onFail){var ret=opts.onFail.call(this);if(typeof ret=='string'){root.innerHTML=ret;}}} -if(IE){window[opts.id]=document.getElementById(opts.id);} -extend(this,{getRoot:function(){return root;},getOptions:function(){return opts;},getConf:function(){return conf;},getApi:function(){return root.firstChild;}});} -var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function string2JsonString(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';} -if(JQUERY){jQuery.tools=jQuery.tools||{version:'@VERSION'};jQuery.tools.flashembed={conf:GLOBAL_OPTS};jQuery.fn.flashembed=function(opts,conf){return this.each(function(){$(this).data("flashembed",flashembed(this,opts,conf));});};}}();$f.addPlugin("ipad",function(options){var STATE_UNLOADED=-1;var STATE_LOADED=0;var STATE_UNSTARTED=1;var STATE_BUFFERING=2;var STATE_PLAYING=3;var STATE_PAUSED=4;var STATE_ENDED=5;var self=this;var currentVolume=1;var onStartFired=false;var stopping=false;var playAfterSeek=false;var activeIndex=0;var activePlaylist=[];var lastSecondTimer;var endTime=null;var startTime=0;var clipDefaults={accelerated:false,autoBuffering:false,autoPlay:true,baseUrl:null,bufferLength:3,connectionProvider:null,cuepointMultiplier:1000,cuepoints:[],controls:{},duration:0,extension:'',fadeInSpeed:1000,fadeOutSpeed:1000,image:false,linkUrl:null,linkWindow:'_self',live:false,metaData:{},originalUrl:null,position:0,playlist:[],provider:'http',scaling:'scale',seekableOnBegin:false,start:0,url:null,urlResolvers:[]};var currentState=STATE_UNLOADED;var previousState=STATE_UNLOADED;var isiDevice=/iPad|iPhone|iPod/i.test(navigator.userAgent);var video=null;function extend(to,from,includeFuncs){if(from){for(key in from){if(key){if(from[key]&&typeof from[key]=="function"&&!includeFuncs) -continue;if(from[key]&&typeof from[key]=="object"&&from[key].length===undefined){var cp={};extend(cp,from[key]);to[key]=cp;}else{to[key]=from[key];}}}} -return to;} -var opts={simulateiDevice:false,controlsSizeRatio:1.5,controls:true,debug:false,validExtensions:'mov|m4v|mp4|avi|mp3|m4a|aac|m3u8|m3u|pls',posterExtensions:'png|jpg'};extend(opts,options);var validExtensions=opts.validExtensions?new RegExp('^\.('+opts.validExtensions+')$','i'):null;var posterExtensions=new RegExp('^\.('+opts.posterExtensions+')$','i');function log(){if(opts.debug){if(isiDevice){var str=[].splice.call(arguments,0).join(', ');console.log.apply(console,[str]);}else{console.log.apply(console,arguments);}}} -function stateDescription(state){switch(state){case-1:return"UNLOADED";case 0:return"LOADED";case 1:return"UNSTARTED";case 2:return"BUFFERING";case 3:return"PLAYING";case 4:return"PAUSED";case 5:return"ENDED";} -return"UNKOWN";} -function actionAllowed(eventName){var ret=$f.fireEvent(self.id(),"onBefore"+eventName,activeIndex);return ret!==false;} -function stopEvent(e){e.stopPropagation();e.preventDefault();return false;} -function setState(state,force){if(currentState==STATE_UNLOADED&&!force) -return;previousState=currentState;currentState=state;stopPlayTimeTracker();if(state==STATE_PLAYING) -startPlayTimeTracker();log(stateDescription(state));} -function resetState(){video.fp_stop();onStartFired=false;stopping=false;playAfterSeek=false;setState(STATE_UNSTARTED);setState(STATE_UNSTARTED);} -var _playTimeTracker=null;function startPlayTimeTracker(){if(_playTimeTracker) -return;console.log("starting tracker");_playTimeTracker=setInterval(onTimeTracked,100);onTimeTracked();} -function stopPlayTimeTracker(){clearInterval(_playTimeTracker);_playTimeTracker=null;} -function onTimeTracked(){var currentTime=Math.floor(video.fp_getTime()*10)*100;var duration=Math.floor(video.duration*10)*100;var fireTime=(new Date()).time;function fireCuePointsIfNeeded(time,cues){time=time>=0?time:duration-Math.abs(time);for(var i=0;ifireTime){cues[i].lastTimeFired=-1;}else if(cues[i].lastTimeFired+500>fireTime){continue;}else{if(time==currentTime||(currentTime-500time)){cues[i].lastTimeFired=fireTime;$f.fireEvent(self.id(),'onCuepoint',activeIndex,cues[i].fnId,cues[i].parameters);}}}} -$f.each(self.getCommonClip().cuepoints,fireCuePointsIfNeeded);$f.each(activePlaylist[activeIndex].cuepoints,fireCuePointsIfNeeded);} -function replay(){resetState();playAfterSeek=true;video.fp_seek(0);} -function scaleVideo(clip){} -function addAPI(){console.log(video);function fixClip(clip){var extendedClip={};extend(extendedClip,clipDefaults);extend(extendedClip,self.getCommonClip());extend(extendedClip,clip);if(extendedClip.ipadUrl) -url=decodeURIComponent(extendedClip.ipadUrl);else if(extendedClip.url) -url=extendedClip.url;if(url&&url.indexOf('://')==-1&&extendedClip.ipadBaseUrl) -url=extendedClip.ipadBaseUrl+'/'+url;else if(url&&url.indexOf('://')==-1&&extendedClip.baseUrl) -url=extendedClip.baseUrl+'/'+url;extendedClip.originalUrl=extendedClip.url;extendedClip.completeUrl=url;extendedClip.extension=extendedClip.completeUrl.substr(extendedClip.completeUrl.lastIndexOf('.'));var queryIndex=extendedClip.extension.indexOf('?');if(queryIndex>-1) -extendedClip.extension=extendedClip.extension.substr(0,queryIndex);extendedClip.type='video';delete extendedClip.index;log("fixed clip",extendedClip);return extendedClip;} -video.fp_play=function(clip,inStream,forcePlay,poster){var url=null;var autoBuffering=true;var autoPlay=true;log("Calling play() "+clip,clip);if(inStream){log("ERROR: inStream clips not yet supported");return;} -if(clip!==undefined){if(typeof clip=="number"){if(activeIndex>=activePlaylist.length) -return;activeIndex=clip;clip=activePlaylist[activeIndex];}else{if(typeof clip=="string"){clip={url:clip};} -video.fp_setPlaylist(clip.length!==undefined?clip:[clip]);} -if(activeIndex==0&&activePlaylist.length>1&&posterExtensions.test(activePlaylist[activeIndex].extension)){var poster=activePlaylist[activeIndex].url;console.log("Poster image available with url "+poster);++activeIndex;console.log("Not last clip in the playlist, moving to next one");video.fp_play(activeIndex,false,true,poster);return;} -if(validExtensions&&!validExtensions.test(activePlaylist[activeIndex].extension)){return;} -clip=activePlaylist[activeIndex];url=clip.completeUrl;if(clip.autoBuffering!==undefined&&clip.autoBuffering===false) -autoBuffering=false;if(clip.autoPlay===undefined||clip.autoPlay===true||forcePlay===true){autoBuffering=true;autoPlay=true;}else{autoPlay=false;}}else{log("clip was not given, simply calling video.play, if not already buffering");if(currentState!=STATE_BUFFERING){video.play();} -return;} -log("about to play "+url,autoBuffering,autoPlay);resetState();if(url){log("Changing SRC attribute"+url);video.setAttribute('src',url);} -if(autoBuffering){if(!actionAllowed('Begin')) -return false;if(poster){autoPlay=clip.autoPlay;video.setAttribute('poster',poster);video.setAttribute('preload',"none");} -$f.fireEvent(self.id(),'onBegin',activeIndex);log("calling video.load()");video.load();} -if(autoPlay){log("calling video.play()");video.play();}} -video.fp_pause=function(){log("pause called");if(!actionAllowed('Pause')) -return false;video.pause();};video.fp_resume=function(){log("resume called");if(!actionAllowed('Resume')) -return false;video.play();};video.fp_stop=function(){log("stop called");if(!actionAllowed('Stop')) -return false;stopping=true;video.pause();try{video.currentTime=0;}catch(ignored){}};video.fp_seek=function(position){log("seek called "+position);if(!actionAllowed('Seek')) -return false;var seconds=0;var position=position+"";if(position.charAt(position.length-1)=='%'){var percentage=parseInt(position.substr(0,position.length-1))/100;var duration=video.duration;seconds=duration*percentage;}else{seconds=position;} -try{video.currentTime=seconds;}catch(e){log("Wrong seek time");}};video.fp_getTime=function(){return video.currentTime;};video.fp_mute=function(){log("mute called");if(!actionAllowed('Mute')) -return false;currentVolume=video.volume;video.volume=0;};video.fp_unmute=function(){if(!actionAllowed('Unmute')) -return false;video.volume=currentVolume;};video.fp_getVolume=function(){return video.volume*100;};video.fp_setVolume=function(volume){if(!actionAllowed('Volume')) -return false;video.volume=volume/100;};video.fp_toggle=function(){log('toggle called');if(self.getState()==STATE_ENDED){replay();return;} -if(video.paused) -video.fp_play();else -video.fp_pause();};video.fp_isPaused=function(){return video.paused;};video.fp_isPlaying=function(){return!video.paused;};video.fp_getPlugin=function(name){if(name=='canvas'||name=='controls'){var config=self.getConfig();return config['plugins']&&config['plugins'][name]?config['plugins'][name]:null;} -log("ERROR: no support for "+name+" plugin on iDevices");return null;};video.fp_close=function(){setState(STATE_UNLOADED);video.parentNode.removeChild(video);video=null;};video.fp_getStatus=function(){var bufferStart=0;var bufferEnd=0;try{bufferStart=video.buffered.start();bufferEnd=video.buffered.end();}catch(ignored){} -return{bufferStart:bufferStart,bufferEnd:bufferEnd,state:currentState,time:video.fp_getTime(),muted:video.muted,volume:video.fp_getVolume()};};video.fp_getState=function(){return currentState;};video.fp_startBuffering=function(){if(currentState==STATE_UNSTARTED) -video.load();};video.fp_setPlaylist=function(playlist){log("Setting playlist");activeIndex=0;for(var i=0;i0){clipDuration=activePlaylist[activeIndex].duration;endTime=clipDuration+startTime;}else{clipDuration=video.duration;endTime=null;} -video.fp_updateClip({duration:clipDuration,metaData:{duration:video.duration}},activeIndex);activePlaylist[activeIndex].duration=video.duration;activePlaylist[activeIndex].metaData={duration:video.duration};$f.fireEvent(self.id(),'onMetaData',activeIndex,activePlaylist[activeIndex]);};video.addEventListener('loadedmetadata',onMetaData,false);video.addEventListener('durationchange',onMetaData,false);var onTimeUpdate=function(e){if(endTime&&video.currentTime>endTime){video.fp_seek(startTime);resetState();return stopEvent(e);}};video.addEventListener("timeupdate",onTimeUpdate,false);var onStart=function(e){if(currentState==STATE_PAUSED){if(!actionAllowed('Resume')){log("Resume disallowed, pausing");video.fp_pause();return stopEvent(e);} -$f.fireEvent(self.id(),'onResume',activeIndex);} -setState(STATE_PLAYING);if(!onStartFired){onStartFired=true;$f.fireEvent(self.id(),'onStart',activeIndex);}};video.addEventListener('playing',onStart,false);var onPlay=function(e){startLastSecondTimer();} -video.addEventListener('play',onPlay,false);var onFinish=function(e){if(!actionAllowed('Finish')){if(activePlaylist.length==1){log("Active playlist only has one clip, onBeforeFinish returned false. Replaying");replay();}else if(activeIndex!=(activePlaylist.length-1)){log("Not the last clip in the playlist, but onBeforeFinish returned false. Returning to the beginning of current clip");video.fp_seek(0);}else{log("Last clip in playlist, but onBeforeFinish returned false, start again from the beginning");video.fp_play(0);} -return stopEvent(e);} -setState(STATE_ENDED);$f.fireEvent(self.id(),'onFinish',activeIndex);if(activePlaylist.length>1&&activeIndex<(activePlaylist.length-1)){log("Not last clip in the playlist, moving to next one");video.fp_play(++activeIndex,false,true);}};video.addEventListener('ended',onFinish,false);var onError=function(e){setState(STATE_LOADED,true);$f.fireEvent(self.id(),'onError',activeIndex,201);if(opts.onFail&&opts.onFail instanceof Function) -opts.onFail.apply(self,[]);};video.addEventListener('error',onError,false);var onPause=function(e){log("got pause event from player"+self.id());if(stopping) -return;if(currentState==STATE_BUFFERING&&previousState==STATE_UNSTARTED){log("forcing play");setTimeout(function(){video.play();},0);return;} -if(!actionAllowed('Pause')){video.fp_resume();return stopEvent(e);} -stopLastSecondTimer();setState(STATE_PAUSED);$f.fireEvent(self.id(),'onPause',activeIndex);} -video.addEventListener('pause',onPause,false);var onSeek=function(e){$f.fireEvent(self.id(),'onBeforeSeek',activeIndex);};video.addEventListener('seeking',onSeek,false);var onSeekDone=function(e){if(stopping){stopping=false;$f.fireEvent(self.id(),'onStop',activeIndex);} -else -$f.fireEvent(self.id(),'onSeek',activeIndex);log("seek done, currentState",stateDescription(currentState));if(playAfterSeek){playAfterSeek=false;video.fp_play();}else if(currentState!=STATE_PLAYING) -video.fp_pause();};video.addEventListener('seeked',onSeekDone,false);var onVolumeChange=function(e){$f.fireEvent(self.id(),'onVolume',video.fp_getVolume());};video.addEventListener('volumechange',onVolumeChange,false);} -function startLastSecondTimer(){lastSecondTimer=setInterval(function(){if(video.fp_getTime()>=video.duration-1){$f.fireEvent(self.id(),'onLastSecond',activeIndex);stopLastSecondTimer();}},100);} -function stopLastSecondTimer(){clearInterval(lastSecondTimer);} -function onPlayerLoaded(){video.fp_play(0);} -function installControlbar(){} -if(isiDevice||opts.simulateiDevice){if(!window.flashembed.__replaced){var realFlashembed=window.flashembed;window.flashembed=function(root,opts,conf){if(typeof root=='string'){root=document.getElementById(root.replace("#",""));} -if(!root){return;} -var style=window.getComputedStyle(root,null);var width=parseInt(style.width);var height=parseInt(style.height);while(root.firstChild) -root.removeChild(root.firstChild);var container=document.createElement('div');var api=document.createElement('video');container.appendChild(api);root.appendChild(container);container.style.height=height+'px';container.style.width=width+'px';container.style.display='block';container.style.position='relative';container.style.background='-webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0.5)), to(rgba(0, 0, 0, 0.7)))';container.style.cursor='default';container.style.webkitUserDrag='none';api.style.height='100%';api.style.width='100%';api.style.display='block';api.id=opts.id;api.name=opts.id;api.style.cursor='pointer';api.style.webkitUserDrag='none';api.type="video/mp4";api.playerConfig=conf.config;$f.fireEvent(conf.config.playerId,'onLoad','player');};flashembed.getVersion=realFlashembed.getVersion;flashembed.asString=realFlashembed.asString;flashembed.isSupported=function(){return true;} -flashembed.__replaced=true;} -var __fireEvent=self._fireEvent;self._fireEvent=function(a){if(a[0]=='onLoad'&&a[1]=='player'){video=self.getParent().querySelector('video');if(opts.controls) -video.controls="controls";addAPI();addListeners();setState(STATE_LOADED,true);video.fp_setPlaylist(video.playerConfig.playlist);onPlayerLoaded();__fireEvent.apply(self,[a]);} -var shouldFireEvent=currentState!=STATE_UNLOADED;if(currentState==STATE_UNLOADED&&typeof a=='string') -shouldFireEvent=true;if(shouldFireEvent) -return __fireEvent.apply(self,[a]);} -self._swfHeight=function(){return parseInt(video.style.height);} -self.hasiPadSupport=function(){return true;}} -return self;}); \ No newline at end of file -- cgit v1.2.3