-
Notifications
You must be signed in to change notification settings - Fork 22
/
jquery.jwplayer.min.js
11 lines (11 loc) · 4.1 KB
/
jquery.jwplayer.min.js
1
2
3
4
5
6
7
8
9
10
11
(function(e){
/*
jQuery.jwPlayer
by Keith C. Ivey, [email protected]
Copyright 2010, Smokescreen Corporation
Dual licensed under the MIT and GPL licenses
http://www.opensource.org/licenses/mit-license.php
http://www.gnu.org/licenses/gpl.html
Version 0.115 (2010-08-18)
*/
var d="jwPlayer";var b={ITEM:"Controller",MUTE:"Controller",PLAY:"Controller",PLAYLIST:"Controller",RESIZE:"Controller",SEEK:"Controller",STOP:"Controller",VOLUME:"Controller",BUFFER:"Model",ERROR:"Model",LOADED:"Model",META:"Model",STATE:"Model",TIME:"Model",FULLSCREEN:"View",LINK:"View",LOAD:"View",NEXT:"View",PREV:"View",REDRAW:"View"};var f={ITEM:{index:"item"},STATE:{newstate:"state"},TIME:{position:"position",duration:"duration"},VOLUME:{volume:"volume"}};var a=["author","autostart","backcolor","bufferlength","config","controlbar","date","debug","description","displaytitle","dock","duration","file","frontcolor","fullscreen","icons","image","item","lightcolor","mute","playerready","playlist","playlistfile","playlistsize","plugins","provider","repeat","screencolor","shuffle","skin","smoothing","start","streamer","stretching","tags","title","volume"];function c(j){var g,h=0;while(true){g=d+"_"+j;if(h){g+=h}if(!window[g]){return g}h++}}e.fn[d]=function(i){var h,g,j,k;if(typeof i=="string"){h=e.fn[d][i];if(!h){throw ("No such method: "+d+"."+i)}g=e.makeArray(arguments).slice(1);j=this.data(d);if(!j){throw ("Constructor not called: "+d+"."+i)}g.unshift(j);return h.apply(this,g)}i=e.extend({},e.fn[d].defaults,i);for(k in i){if(e.inArray(k,a)!=-1){i.flashvars[k]=i[k];delete i[k]}}if(i.height.toString().match(/^[0-9]+$/)){i.height+="px"}if(i.width.toString().match(/^[0-9]+$/)){i.width+="px"}return this.each(function(p){var m=i.id,r=e(this);if(p){m+="-"+p}if(e("#"+m).length){e.error('id "'+m+'" already exists in document')}function t(w,v){return function(y){var z,x;for(z in w){r[d]("set",w[z],y[z])}if(v=="statelistener"){x=r[d]("get","seek");if((y.newstate=="PAUSED"||y.newstate=="PLAYING")&&x!==false){r[d]("set","seek",false);r[d]("seek",x)}}if(i[v]){i[v](y)}}}var o,q,u,s={};for(o in b){q=o.toLowerCase()+"listener";if(f[o]){u=f[o];s[o]=t(u,q)}else{if(i[q]){s[o]=i[q]}}}var n=c("playerReady");var l=i.flashvars.playerready;window[n]=function(x){var w={obj:e("#"+m)[0],duration:null,item:0,state:"IDLE",position:0,seek:false,volume:null};r.data(d,w);var v;for(v in s){r[d]("addListener",v,s[v])}r.addClass(d);if(l){l(x)}};i.flashvars.playerready=n;r.empty().flash({swf:i.swf,id:m,name:m,height:i.height,width:i.width,wmode:i.wmode,params:{allowfullscreen:"true",allowscriptaccess:"always",enablejs:"true",flashvars:i.flashvars}});return this})};e.extend(e.fn[d],{defaults:{flashvars:{},height:240,width:320,id:d,swf:"player.swf",wmode:"opaque"},set:function(i,h,g){i[h]=g},get:function(h,g){return h[g]},item:function(h,g){g=parseInt(g,10);h.obj.sendEvent("ITEM",g);return this},load:function(h,g){h.obj.sendEvent("LOAD",g);return this},mute:function(g){g.obj.sendEvent("MUTE");return this},next:function(g){g.obj.sendEvent("NEXT");return this},pause:function(g){g.obj.sendEvent("PLAY","false");return this},play:function(g){g.obj.sendEvent("PLAY","true");return this},resume:function(g){g.obj.sendEvent("PLAY","true");return this},start:function(g){g.obj.sendEvent("PLAY","true");return this},togglePlay:function(g){g.obj.sendEvent("PLAY");return this},prev:function(g){g.obj.sendEvent("PREV");return this},redraw:function(g){g.obj.sendEvent("REDRAW");return this},seek:function(i,g){var h;g=parseFloat(g);if(!g){g=0.001}h=this[d]("get","state");if(h=="PLAYING"||h=="PAUSED"){i.obj.sendEvent("SEEK",g);i.seek=false}else{if(h=="IDLE"){i.obj.sendEvent("PLAY","true");i.obj.sendEvent("PLAY","false")}i.seek=g}return this},stop:function(g){g.obj.sendEvent("STOP");return this},volume:function(h,g){g=parseInt(g,10);h.obj.sendEvent("VOLUME",g);return this},getConfig:function(i,h){var g=i.obj.getConfig();return h?g[h]:g},getPlaylist:function(h,g){var i=h.obj.getPlaylist();return g||g===0?i[g]:i},addListener:function(h,g,k){var j,i="add"+b[g]+"Listener";if(e.isFunction(k)){j=c(g.toLowerCase()+"Listener");window[j]=k;k=j}return h.obj[i](g,k)},destroy:function(){e(this).removeData(d).empty()}})})(jQuery);