Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated the media player so that the flash will accept other booleans.

  • Loading branch information...
commit 2755c7de87fae37b1891444c8cf24d0946ddea7d 0 parents
@travist authored
Showing with 17,673 additions and 0 deletions.
  1. +5 −0 README.md
  2. +55 −0 bin/drupal.media.player.compressed.js
  3. +2,217 −0 bin/drupal.media.player.js
  4. +400 −0 doc/files.html
  5. +331 −0 doc/index.html
  6. +277 −0 doc/symbols/_global_.html
  7. +572 −0 doc/symbols/media.compatibility.html
  8. +605 −0 doc/symbols/media.controllers.base.html
  9. +458 −0 doc/symbols/media.display.html
  10. +570 −0 doc/symbols/media.file.html
  11. +549 −0 doc/symbols/media.flags.html
  12. +504 −0 doc/symbols/media.playLoader.base.html
  13. +1,024 −0 doc/symbols/media.player.html
  14. +1,092 −0 doc/symbols/media.players.base.html
  15. +1,026 −0 doc/symbols/media.players.flash.html
  16. +1,031 −0 doc/symbols/media.players.html5.html
  17. +1,042 −0 doc/symbols/media.players.minplayer.html
  18. +1,183 −0 doc/symbols/media.players.youtube.html
  19. +450 −0 doc/symbols/media.plugin.html
  20. +459 −0 doc/symbols/media.templates.base.html
  21. +89 −0 doc/symbols/src/js_source_drupal.media.compatibility.js.html
  22. +234 −0 doc/symbols/src/js_source_drupal.media.controllers.base.js.html
  23. +62 −0 doc/symbols/src/js_source_drupal.media.display.js.html
  24. +152 −0 doc/symbols/src/js_source_drupal.media.file.js.html
  25. +79 −0 doc/symbols/src/js_source_drupal.media.flags.js.html
  26. +127 −0 doc/symbols/src/js_source_drupal.media.playLoader.base.js.html
  27. +311 −0 doc/symbols/src/js_source_drupal.media.player.js.html
  28. +193 −0 doc/symbols/src/js_source_drupal.media.players.base.js.html
  29. +247 −0 doc/symbols/src/js_source_drupal.media.players.flash.js.html
  30. +247 −0 doc/symbols/src/js_source_drupal.media.players.html5.js.html
  31. +224 −0 doc/symbols/src/js_source_drupal.media.players.minplayer.js.html
  32. +262 −0 doc/symbols/src/js_source_drupal.media.players.youtube.js.html
  33. +48 −0 doc/symbols/src/js_source_drupal.media.plugin.js.html
  34. +54 −0 doc/symbols/src/js_source_drupal.media.templates.base.js.html
  35. +89 −0 doc/symbols/src/src_drupal.media.compatibility.js.html
  36. +234 −0 doc/symbols/src/src_drupal.media.controllers.base.js.html
  37. +62 −0 doc/symbols/src/src_drupal.media.display.js.html
  38. +152 −0 doc/symbols/src/src_drupal.media.file.js.html
  39. +79 −0 doc/symbols/src/src_drupal.media.flags.js.html
  40. +127 −0 doc/symbols/src/src_drupal.media.playLoader.base.js.html
  41. +311 −0 doc/symbols/src/src_drupal.media.player.js.html
  42. +193 −0 doc/symbols/src/src_drupal.media.players.base.js.html
  43. +247 −0 doc/symbols/src/src_drupal.media.players.flash.js.html
Sorry, we could not display the entire diff because it was too big.
5 README.md
@@ -0,0 +1,5 @@
+The Drupal Media Player
+===================================
+
+
+
55 bin/drupal.media.player.compressed.js
@@ -0,0 +1,55 @@
+Drupal.media=Drupal.media||{};(function(d){function a(a,c){if("function"===typeof a.canPlayType){var e=a.canPlayType(c);return"no"!==e&&""!==e}return!1}d.compatibility=function(){var b=null,b=document.createElement("video");this.videoOGG=a(b,"video/ogg");this.videoH264=a(b,"video/mp4");this.videoWEBM=a(b,"video/x-webm");b=document.createElement("audio");this.audioOGG=a(b,"audio/ogg");this.audioMP3=a(b,"audio/mpeg");this.audioMP4=a(b,"audio/mp4")};if(!d.playTypes)d.playTypes=new d.compatibility})(Drupal.media);
+Drupal.media=Drupal.media||{};(function(d){d.flags=function(){this.flag=0;this.ids={};this.numFlags=0};d.flags.prototype.setFlag=function(a,b){if(!this.ids.hasOwnProperty(a))this.ids[a]=this.numFlags,this.numFlags++;this.flag=b?this.flag|1<<this.ids[a]:this.flag&~(1<<this.ids[a])}})(Drupal.media);Drupal.media=Drupal.media||{};(function(d){d.plugin=function(a){this.player=null;a&&this.construct()};d.plugin.prototype.construct=function(){};d.plugin.prototype.setPlayer=function(a){this.player=a}})(Drupal.media);
+Drupal.media=Drupal.media||{};(function(d,a){a.display=function(b,c){if(b)this.display=d(b),this.options=c,this.options.elements=this.options.elements||{},d.extend(this.options.elements,this.getElements()),this.elements=this.options.elements;a.plugin.call(this,b,c)};a.display.prototype=new a.plugin;a.display.prototype.constructor=a.display;a.display.prototype.getElements=function(){return{}};a.display.prototype.isValid=function(){return 0<this.display.length}})(jQuery,Drupal.media);
+Drupal.media=Drupal.media||{};
+(function(d,a){if(!d.fn.mediaplayer)d.fn.mediaplayer=function(b){return d(this).each(function(){a.player[d(this).selector]||new a.player(d(this),b)})};a.player=function(b,c){c=d.extend({id:"player",controller:"default",template:"default",volume:80,swfplayer:"",wmode:"transparent",attributes:{},settings:{}},c);a.player[c.id]=this;a.display.call(this,b,c)};a.player.prototype=new a.display;a.player.prototype.constructor=a.player;a.player.prototype.construct=function(){a.display.prototype.construct.call(this);var b=
+{},c=null,c=null,e=a.plugins.length,f=[];this.media=b=null;for(this.allPlugins={};e--;)b=a.plugins[e],c=b.element?d(b.element,this.display):this.display,c=new b.object(c,this.options),this.addPlugin(b.id,c);this.currentPlayer="html5";this.elements.media&&((b=this.elements.media.attr("src"))&&f.push({path:b}),d("source",this.elements.media).each(function(){f.push({path:d(this).attr("src"),mimetype:d(this).attr("type"),codecs:d(this).attr("codecs")})}));d(window).bind("keyup",{obj:this},function(a){a.data.obj.display.hasClass("fullscreen")&&
+(113===a.keyCode||27===a.keyCode)&&a.data.obj.display.removeClass("fullscreen")});this.load(f)};a.player.prototype.getMediaFile=function(b){if("string"===typeof b)return new a.file({path:b});if(b.path)return new a.file(b);for(var c=b.length,e=null,f=null;c--;)f=b[c],f="string"===typeof f?new a.file({path:f}):new a.file(f),0<f.priority&&(e=f);return e};a.player.prototype.load=function(b){var b=this.getMediaFile(b),c="",e="";if(b){if(!this.media||b.player.toString()!==this.currentPlayer){this.currentPlayer=
+b.player.toString();this.media&&this.media.destroy();if(this.elements.display)e=a.players[b.player],this.media=new e(this.elements.display,this.options,b);for(c in this.allPlugins)this.allPlugins.hasOwnProperty(c)&&this.allPlugins[c].setPlayer(this.media)}this.media&&this.media.load(b)}};a.player.prototype.addPlugin=function(a,c){c.isValid()&&(this.allPlugins[a]=c)};a.player.prototype.getPlugin=function(a){return this.allPlugins[a]};a.player.prototype.play=function(){this.media&&this.media.play()};
+a.player.prototype.pause=function(){this.media&&this.media.pause()};a.player.prototype.stop=function(){this.media&&this.media.stop()};a.player.prototype.seek=function(a){this.media&&this.media.seek(a)};a.player.prototype.setVolume=function(a){this.media&&this.media.setVolume(a)};a.player.prototype.getVolume=function(){return this.media?this.media.getVolume():0};a.player.prototype.getDuration=function(){return this.media?this.media.getDuration():0}})(jQuery,Drupal.media);
+Drupal.media=Drupal.media||{};
+(function(d){d.file=function(a){this.duration=a.duration||0;this.bytesTotal=a.bytesTotal||0;this.quality=a.quality||0;this.stream=a.stream||"";this.path=a.path||"";this.codecs=a.codecs||"";this.extension=a.extension||this.getFileExtension();this.mimetype=a.mimetype||this.getMimeType();this.type=a.type||this.getType();this.player=a.player||this.getBestPlayer();this.priority=a.priority||this.getPriority()};d.file.prototype.getBestPlayer=function(){var a=null,b=0,c=this;jQuery.each(d.players,function(e,
+f){var d=f.getPriority();f.canPlay(c)&&d>b&&(a=e,b=d)});return a};d.file.prototype.getPriority=function(){var a=1;this.player&&(a=d.players[this.player].getPriority());switch(this.mimetype){case "video/x-webm":return 10*a;case "video/mp4":case "audio/mp4":case "audio/mpeg":return 9*a;case "video/ogg":case "audio/ogg":case "video/quicktime":return 8*a;default:return 5*a}};d.file.prototype.getFileExtension=function(){return this.path.substring(this.path.lastIndexOf(".")+1).toLowerCase()};d.file.prototype.getMimeType=
+function(){switch(this.extension){case "mp4":case "m4v":case "flv":case "f4v":return"video/mp4";case "webm":return"video/x-webm";case "ogg":case "ogv":return"video/ogg";case "3g2":return"video/3gpp2";case "3gpp":case "3gp":return"video/3gpp";case "mov":return"video/quicktime";case "swf":return"application/x-shockwave-flash";case "oga":return"audio/ogg";case "mp3":return"audio/mpeg";case "m4a":case "f4a":return"audio/mp4";case "aac":return"audio/aac";case "wav":return"audio/vnd.wave";case "wma":return"audio/x-ms-wma";
+default:return"unknown"}};d.file.prototype.getType=function(){switch(this.mimetype){case "video/mp4":case "video/x-webm":case "video/ogg":case "video/3gpp2":case "video/3gpp":case "video/quicktime":return"video";case "audio/mp3":case "audio/mp4":case "audio/ogg":return"audio";default:return"unknown"}}})(Drupal.media);Drupal.media=Drupal.media||{};
+(function(d,a){a.playLoader=a.playLoader||{};a.playLoader.base=function(b,c){this.busy=new a.flags;this.bigPlay=new a.flags;a.display.call(this,b,c)};a.playLoader.base.prototype=new a.display;a.playLoader.base.prototype.constructor=a.playLoader.base;a.playLoader.base.prototype.construct=function(){a.display.prototype.construct.call(this);this.elements.bigPlay&&this.elements.bigPlay.bind("click",{obj:this},function(a){a.preventDefault();d(this).hide();a.data.obj.player&&a.data.obj.player.play()})};
+a.playLoader.base.prototype.checkVisibility=function(){this.busy.flag?this.elements.busy.show():this.elements.busy.hide();this.bigPlay.flag?this.elements.bigPlay.show():this.elements.bigPlay.hide();(this.bigPlay.flag||this.busy.flag)&&this.display.show();!this.bigPlay.flag&&!this.busy.flag&&this.display.hide()};a.playLoader.base.prototype.setPlayer=function(b){a.display.prototype.setPlayer.call(this,b);var c=this;b.display.bind("loadstart",function(){c.busy.setFlag("media",!0);c.bigPlay.setFlag("media",
+!0);c.checkVisibility()});b.display.bind("waiting",function(){c.busy.setFlag("media",!0);c.checkVisibility()});b.display.bind("loadedmetadata",function(){c.busy.setFlag("media",!1);c.checkVisibility()});b.display.bind("loadeddata",function(){c.busy.setFlag("media",!1);c.checkVisibility()});b.display.bind("playing",function(){c.busy.setFlag("media",!1);c.bigPlay.setFlag("media",!1);c.checkVisibility()});b.display.bind("pause",function(){c.bigPlay.setFlag("media",!0);c.checkVisibility()})}})(jQuery,
+Drupal.media);Drupal.media=Drupal.media||{};
+(function(d,a){a.players=a.players||{};a.players.base=function(b,c,e){this.mediaFile=e;a.display.call(this,b,c)};a.players.base.prototype=new a.display;a.players.base.prototype.constructor=a.players.base;a.players.base.getPriority=function(){return 0};a.players.base.canPlay=function(){return!1};a.players.base.prototype.construct=function(){a.display.prototype.construct.call(this);this.playerFound()||(this.display.unbind(),this.elements.media&&this.elements.media.remove(),this.display.html(this.create()));
+this.player=this.getPlayer();this.trigger=function(a,c){this.display.trigger(a,c)};this.currentTime=this.duration=0};a.players.base.prototype.playerFound=function(){return!1};a.players.base.prototype.create=function(){return null};a.players.base.prototype.getPlayer=function(){return null};a.players.base.prototype.destroy=function(){};a.players.base.prototype.load=function(a){this.mediaFile=a};a.players.base.prototype.play=function(){};a.players.base.prototype.pause=function(){};a.players.base.prototype.stop=
+function(){};a.players.base.prototype.seek=function(){};a.players.base.prototype.setVolume=function(a){this.trigger("volumeupdate",a)};a.players.base.prototype.getVolume=function(){return 0};a.players.base.prototype.getDuration=function(){return 0}})(jQuery,Drupal.media);Drupal.media=Drupal.media||{};
+(function(d,a){a.players=a.players||{};a.players.html5=function(b,c,e){a.players.base.call(this,b,c,e)};a.players.html5.prototype=new a.players.base;a.players.html5.prototype.constructor=a.players.html5;a.players.html5.getPriority=function(){return 10};a.players.html5.canPlay=function(b){switch(b.mimetype){case "video/ogg":return a.playTypes.videoOGG;case "video/mp4":return a.playTypes.videoH264;case "video/x-webm":return a.playTypes.videoWEBM;case "audio/ogg":return a.playTypes.audioOGG;case "audio/mpeg":return a.playTypes.audioMP3;
+case "audio/mp4":return a.playTypes.audioMP4;default:return!1}};a.players.html5.prototype.construct=function(){a.players.base.prototype.construct.call(this);this.loaded=!1;var b=this;if(this.player)this.player.addEventListener("abort",function(){b.trigger("abort")},!0),this.player.addEventListener("loadstart",function(){b.trigger("loadstart")},!0),this.player.addEventListener("loadeddata",function(){b.trigger("loadeddata")},!0),this.player.addEventListener("loadedmetadata",function(){b.trigger("loadedmetadata")},
+!0),this.player.addEventListener("canplaythrough",function(){b.trigger("canplaythrough")},!0),this.player.addEventListener("ended",function(){b.trigger("ended")},!0),this.player.addEventListener("pause",function(){b.trigger("pause")},!0),this.player.addEventListener("play",function(){b.trigger("play")},!0),this.player.addEventListener("playing",function(){b.trigger("playing")},!0),this.player.addEventListener("error",function(){b.trigger("error")},!0),this.player.addEventListener("waiting",function(){b.trigger("waiting")},
+!0),this.player.addEventListener("timeupdate",function(){var a=this.duration,e=this.currentTime;b.duration=a;b.currentTime=e;b.trigger("timeupdate",{currentTime:e,duration:a})},!0),this.player.addEventListener("durationchange",function(){b.duration=this.duration;b.trigger("durationchange",{duration:this.duration})},!0),this.player.addEventListener("progress",function(a){b.trigger("progress",{loaded:a.loaded,total:a.total})},!0),this.autoBuffer()?this.player.autobuffer=!0:(this.player.autobuffer=!1,
+this.player.preload="none")};a.players.html5.prototype.autoBuffer=function(){var a="none"!==this.player.preload;return"function"===typeof this.player.hasAttribute?this.player.hasAttribute("preload")&&a:!1};a.players.html5.prototype.playerFound=function(){return 0<this.display.find(this.mediaFile.type).length};a.players.html5.prototype.create=function(){var a=document.createElement(this.mediaFile.type),c="";for(c in this.options.attributes)this.options.attributes.hasOwnProperty(c)&&a.setAttribute(c,
+this.options.attributes[c]);return a};a.players.html5.prototype.getPlayer=function(){return this.options.elements.media.eq(0)[0]};a.players.html5.prototype.load=function(b){a.players.base.prototype.load.call(this,b);if(this.loaded){var c='<source src="'+b.path+'" ',c=c+('type="'+b.mimetype+'"'),c=c+(b.codecs?' codecs="'+b.path+'">':">");this.options.elements.player.attr("src","").empty().html(c)}this.loaded=!0};a.players.html5.prototype.play=function(){a.players.base.prototype.play.call(this);this.player.play()};
+a.players.html5.prototype.pause=function(){a.players.base.prototype.pause.call(this);this.player.pause()};a.players.html5.prototype.stop=function(){a.players.base.prototype.stop.call(this);this.media.pause();this.player.src=""};a.players.html5.prototype.seek=function(b){a.players.base.prototype.seek.call(this,b);this.player.currentTime=b};a.players.html5.prototype.setVolume=function(b){a.players.base.prototype.setVolume.call(this,b);this.player.volume=b};a.players.html5.prototype.getVolume=function(){return this.player.volume};
+a.players.html5.prototype.getDuration=function(){var a=this.player.duration;return Infinity===a?0:a}})(jQuery,Drupal.media);Drupal.media=Drupal.media||{};
+(function(d,a){a.players=a.players||{};a.players.flash=function(b,c,e){this.mediaInterval=this.durationInterval=null;this.duration=0;this.ready=!1;a.players.base.call(this,b,c,e)};a.players.flash.prototype=new a.players.base;a.players.flash.prototype.constructor=a.players.flash;a.players.flash.getPriority=function(){return 0};a.players.flash.canPlay=function(){return!1};a.players.flash.getFlash=function(a){var c=window.location.protocol,e=null,f=null,g="",h={},f=null;":"===c.charAt(c.length-1)&&c.substring(0,
+c.length-1);e=document.createElement("object");e.setAttribute("width",a.width);e.setAttribute("height",a.height);e.setAttribute("id",a.id);e.setAttribute("name",a.id);e.setAttribute("playerType",a.playerType);h={allowScriptAccess:"always",allowfullscreen:"true",movie:a.swf,wmode:a.wmode,quality:"high",FlashVars:d.param(a.flashvars)};for(g in h)h.hasOwnProperty(g)&&(f=document.createElement("param"),f.setAttribute("name",g),f.setAttribute("value",h[g]),e.appendChild(f));f=document.createElement("embed");
+for(g in h)h.hasOwnProperty(g)&&(g="movie"===g?"src":g,f.setAttribute(g,h[g]));f.setAttribute("width",a.width);f.setAttribute("height",a.height);f.setAttribute("id",a.id);f.setAttribute("name",a.id);f.setAttribute("swLiveConnect","true");f.setAttribute("type","application/x-shockwave-flash");e.appendChild(f);return e};a.players.flash.prototype.onReady=function(){var a=this;this.ready=!0;this.trigger("loadstart");this.durationInterval=setInterval(function(){a.getDuration()&&(clearInterval(a.durationInterval),
+a.trigger("durationchange",{duration:a.getDuration()}))},1E3)};a.players.flash.prototype.onPlaying=function(){var a=this;this.trigger("playing");this.mediaInterval=setInterval(function(){var c=a.getCurrentTime(),e=a.getDuration();a.trigger("timeupdate",{currentTime:c,duration:e})},1E3)};a.players.flash.prototype.onPaused=function(){this.trigger("pause");clearInterval(this.mediaInterval)};a.players.flash.prototype.onMeta=function(){clearInterval(this.durationInterval);this.trigger("loadeddata");this.trigger("loadedmetadata");
+this.trigger("durationchange",{duration:this.getDuration()})};a.players.flash.prototype.reset=function(){this.ready=!1;this.duration=0};a.players.flash.prototype.destroy=function(){this.reset()};a.players.flash.prototype.playerFound=function(){return 0<this.display.find('object[playerType="flash"]').length};a.players.flash.prototype.create=function(){this.reset();return null};a.players.flash.prototype.getPlayer=function(){return d(d.browser.msie?"object":"embed",this.display).eq(0)[0]};a.players.flash.prototype.load=
+function(b){this.duration=0;a.players.base.prototype.load.call(this,b)};a.players.flash.prototype.getPlayerDuration=function(){return 0};a.players.flash.prototype.getDuration=function(){if(this.duration)return this.duration;return this.isReady()?this.duration=this.getPlayerDuration():a.players.base.prototype.getDuration.call(this)};a.players.flash.prototype.isReady=function(){return this.player&&this.ready}})(jQuery,Drupal.media);Drupal.media=Drupal.media||{};
+(function(d,a){a.players=a.players||{};a.players.minplayer=function(b,e,f){this.onMediaUpdate=function(b){if(this.ready)switch(b){case "mediaMeta":a.players.flash.prototype.onMeta.call(this);break;case "mediaPlaying":a.players.flash.prototype.onPlaying.call(this);break;case "mediaPaused":a.players.flash.prototype.onPaused.call(this)}};a.players.flash.call(this,b,e,f)};a.players.minplayer.prototype=new a.players.flash;a.players.minplayer.prototype.constructor=a.players.minplayer;window.onFlashPlayerReady=
+function(b){if(a.player[b])a.player[b].media.onReady()};window.onFlashPlayerUpdate=function(b,e){if(a.player[b])a.player[b].media.onMediaUpdate(e)};var b=console||{log:function(){}};window.onFlashPlayerDebug=function(a){b.log(a)};a.players.minplayer.getPriority=function(){return 1};a.players.minplayer.canPlay=function(a){switch(a.mimetype){case "video/mp4":case "video/x-webm":case "video/quicktime":case "video/3gpp2":case "video/3gpp":case "application/x-shockwave-flash":case "audio/mpeg":case "audio/mp4":case "audio/aac":case "audio/vnd.wave":case "audio/x-ms-wma":return!0;
+default:return!1}};a.players.minplayer.prototype.create=function(){a.players.flash.prototype.create.call(this);return a.players.flash.getFlash({swf:this.options.swfplayer,id:this.options.id+"_player",playerType:"flash",width:this.options.settings.width,height:"100%",flashvars:{id:this.options.id,debug:this.options.settings.debug,config:"nocontrols",file:this.mediaFile.path,autostart:this.options.settings.autoplay},wmode:this.options.wmode})};a.players.minplayer.prototype.load=function(b){a.players.flash.prototype.load.call(this,
+b);this.isReady()&&this.player.loadMedia(this.mediaFile.path,this.mediaFile.stream)};a.players.minplayer.prototype.play=function(){a.players.flash.prototype.play.call(this);this.isReady()&&this.player.playMedia()};a.players.minplayer.prototype.pause=function(){a.players.flash.prototype.pause.call(this);this.isReady()&&this.player.pauseMedia()};a.players.minplayer.prototype.stop=function(){a.players.flash.prototype.stop.call(this);this.isReady()&&this.player.stopMedia()};a.players.minplayer.prototype.seek=
+function(b){a.players.flash.prototype.seek.call(this,b);this.isReady()&&this.player.seekMedia(b)};a.players.minplayer.prototype.setVolume=function(b){a.players.flash.prototype.setVolume.call(this,b);this.isReady()&&this.player.setVolume(b)};a.players.minplayer.prototype.getVolume=function(){return this.isReady()?this.player.getVolume():a.players.flash.prototype.getVolume.call(this)};a.players.minplayer.prototype.getPlayerDuration=function(){return this.isReady()?this.player.getDuration():0};a.players.minplayer.prototype.getCurrentTime=
+function(){return this.isReady()?this.player.getCurrentTime():0};a.players.minplayer.prototype.getBytesLoaded=function(){return this.isReady()?this.player.getMediaBytesLoaded():0};a.players.minplayer.prototype.getBytesTotal=function(){return this.isReady()?this.player.getMediaBytesTotal():0}})(jQuery,Drupal.media);Drupal.media=Drupal.media||{};
+(function(d,a){a.players=a.players||{};a.players.youtube=function(b,c,e){a.players.flash.call(this,b,c,e);this.quality="default"};a.players.youtube.prototype=new a.players.flash;a.players.youtube.prototype.constructor=a.players.youtube;window.onYouTubePlayerReady=function(b){if(a.player[b])a.player[b].media.onReady()};a.players.youtube.prototype.construct=function(){a.players.flash.prototype.construct.call(this);this.getPlayerState=function(a){switch(a){case 5:return"ready";case 3:return"waiting";
+case 2:return"pause";case 1:return"play";case 0:return"ended";case -1:return"abort";default:return"unknown"}};var b=this;window[this.options.id+"StateChange"]=function(a){b.trigger(b.getPlayerState(a))};window[this.options.id+"PlayerError"]=function(a){b.trigger("error",a)};window[this.options.id+"QualityChange"]=function(a){b.quality=a};if(this.player){var c=this.options.id+"PlayerError",e=this.options.id+"QualityChange";this.player.addEventListener("onStateChange",this.options.id+"StateChange");
+this.player.addEventListener("onError",c);this.player.addEventListener("onPlaybackQualityChange",e)}};a.players.youtube.getPriority=function(){return 10};a.players.youtube.canPlay=function(a){return"video/youtube"===a.mimetype?!0:0===a.path.search(/^http(s)?\:\/\/(www\.)?youtube\.com/i)};a.players.youtube.prototype.create=function(){a.players.base.prototype.flash.call(this);var b={file:this.mediaFile.path,autostart:this.options.settings.autoplay},c="http://www.youtube.com/apiplayer?rand="+Math.floor(1E6*
+Math.random()),c=c+"&amp;version=3&amp;enablejsapi=1&amp;playerapiid="+this.options.id;return a.players.flash.getFlash({swf:c,id:this.options.id+"_player",playerType:"flash",width:this.options.settings.width,height:"100%",flashvars:b,wmode:this.options.wmode})};a.players.youtube.prototype.regex=function(){return/^http[s]?\:\/\/(www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9]+)/i};a.players.youtube.prototype.load=function(b){a.players.flash.prototype.load.call(this,b);if(this.isReady()){var b=this.regex(),
+c="",c=0===this.mediaFile.path.search(b)?this.mediaFile.path.replace(b,"$2"):this.mediaFile.path;this.player.loadVideoById(c,0,this.quality)}};a.players.youtube.prototype.play=function(){a.players.flash.prototype.play.call(this);this.isReady()&&this.player.playVideo()};a.players.youtube.prototype.pause=function(){a.players.flash.prototype.pause.call(this);this.isReady()&&this.player.pauseVideo()};a.players.youtube.prototype.stop=function(){a.players.flash.prototype.stop.call(this);this.isReady()&&
+this.player.stopVideo()};a.players.youtube.prototype.seek=function(b){a.players.flash.prototype.seek.call(this,b);this.isReady()&&this.player.seekTo(b,!0)};a.players.youtube.prototype.setVolume=function(b){a.players.flash.prototype.setVolume.call(this,b);this.isReady()&&this.player.setVolume(100*b)};a.players.youtube.prototype.getVolume=function(){return this.isReady()?this.player.getVolume()/100:a.players.flash.prototype.getVolume.call(this)};a.players.youtube.prototype.getPlayerDuration=function(){return this.isReady()?
+this.player.getDuration():0};a.players.youtube.prototype.getCurrentTime=function(){return this.isReady()?this.player.getCurrentTime():0};a.players.youtube.prototype.getBytesLoaded=function(){return this.isReady()?this.player.getVideoBytesLoaded():0};a.players.youtube.prototype.getBytesTotal=function(){return this.isReady()?this.player.getVideoBytesTotal():0}})(jQuery,Drupal.media);Drupal.media=Drupal.media||{};
+(function(d,a){a.controllers=a.controllers||{};a.controllers.base=function(b,c){a.display.call(this,b,c)};a.controllers.base.prototype=new a.display;a.controllers.base.prototype.constructor=a.controllers.base;a.formatTime=function(a){var a=a||0,c=0,e=0,f=0,d="",f=Math.floor(a/3600),a=a-3600*f,e=Math.floor(a/60),c=Math.floor((a-60*e)%60);f&&(d=d+(""+f)+":");return{time:d+(10<=e?""+e:"0"+e)+":"+(10<=c?""+c:"0"+c),units:""}};a.controllers.base.prototype.getElements=function(){var b=a.display.prototype.getElements.call(this);
+return d.extend(b,{play:null,pause:null,fullscreen:null,seek:null,volume:null,timer:null})};a.controllers.base.prototype.construct=function(){function b(a,b){var c=b?"play":"pause";a.display.trigger(c);a.setPlayPause(b);if(a.player)a.player[c]()}a.display.prototype.construct.call(this);this.elements.play&&this.elements.play.bind("click",{obj:this},function(a){a.preventDefault();b(a.data.obj,!0)});this.elements.pause&&this.elements.pause.bind("click",{obj:this},function(a){a.preventDefault();b(a.data.obj,
+!1)});var c=this,e={};this.elements.fullscreen&&this.elements.fullscreen.click(function(){c.elements.player.hasClass("fullscreen")?c.elements.player.removeClass("fullscreen"):c.elements.player.addClass("fullscreen")}).css({pointer:"hand"});this.dragging=!1;if(this.elements.seek)this.seekBar=this.elements.seek.slider({range:"min"});if(this.elements.volume)e={range:"min",orientation:"vertical"},this.volumeBar=this.elements.volume.slider(e)};a.controllers.base.prototype.setPlayPause=function(a){var c=
+"";this.elements.play&&this.elements.play.css("display",a?"inherit":"none");this.elements.pause&&this.elements.pause.css("display",a?"none":"inherit")};a.controllers.base.prototype.setTimeString=function(b,c){this.elements[b]&&this.elements[b].text(a.formatTime(c).time)};a.controllers.base.prototype.setPlayer=function(b){a.display.prototype.setPlayer.call(this,b);b.display.bind("pause",{obj:this},function(a){a.data.obj.setPlayPause(!0);clearInterval(a.data.obj.interval)});b.display.bind("playing",
+{obj:this},function(a){a.data.obj.setPlayPause(!1)});b.display.bind("durationchange",{obj:this},function(a,b){a.data.obj.setTimeString("duration",b.duration)});b.display.bind("timeupdate",{obj:this},function(a,b){if(!a.data.obj.dragging){var c=0;b.duration&&(c=100*(b.currentTime/b.duration));a.data.obj.seekBar&&a.data.obj.seekBar.slider("option","value",c);a.data.obj.setTimeString("timer",b.currentTime)}});if(this.seekBar){var c=this;this.seekBar.slider({start:function(){c.dragging=!0},stop:function(a,
+d){c.dragging=!1;var g=d.value/100*b.getDuration();b.seek(g)},slide:function(a,d){var g=d.value/100*b.getDuration();c.dragging||b.seek(g);c.setTimeString("timer",g)}})}b.setVolume(this.options.volume/100);this.volumeBar&&(this.volumeBar.slider("option","value",this.options.volume),this.volumeBar.slider({slide:function(a,c){b.setVolume(c.value/100)}}))}})(jQuery,Drupal.media);Drupal.media=Drupal.media||{};
+(function(d,a){a.templates=a.templates||{};a.templates.base=function(b,c){a.display.call(this,b,c)};a.templates.base.prototype=new a.display;a.templates.base.prototype.getElements=function(){var b=a.display.prototype.getElements.call(this);return d.extend(b,{player:null,display:null,media:null})};a.templates.base.prototype.onFullScreen=function(){}})(jQuery,Drupal.media);
2,217 bin/drupal.media.player.js
@@ -0,0 +1,2217 @@
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function(media) {
+
+ // Private function to check a single element's play type.
+ function checkPlayType(elem, playType) {
+ if ((typeof elem.canPlayType) === 'function') {
+ var canPlay = elem.canPlayType(playType);
+ return ('no' !== canPlay) && ('' !== canPlay);
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @class This class is used to define the types of media that can be played
+ * within the browser.
+ * <p>
+ * <strong>Usage:</strong>
+ * <pre><code>
+ * var playTypes = new media.compatibility();
+ *
+ * if (playTypes.videoOGG) {
+ * console.log("This browser can play OGG video");
+ * }
+ *
+ * if (playTypes.videoH264) {
+ * console.log("This browser can play H264 video");
+ * }
+ *
+ * if (playTypes.videoWEBM) {
+ * console.log("This browser can play WebM video");
+ * }
+ *
+ * if (playTypes.audioOGG) {
+ * console.log("This browser can play OGG audio");
+ * }
+ *
+ * if (playTypes.audioMP3) {
+ * console.log("This browser can play MP3 audio");
+ * }
+ *
+ * if (playTypes.audioMP4) {
+ * console.log("This browser can play MP4 audio");
+ * }
+ * </code></pre>
+ */
+ media.compatibility = function() {
+ var elem = null;
+
+ // Create a video element.
+ elem = document.createElement('video');
+
+ /** Can play OGG video */
+ this.videoOGG = checkPlayType(elem, 'video/ogg');
+
+ /** Can play H264 video */
+ this.videoH264 = checkPlayType(elem, 'video/mp4');
+
+ /** Can play WEBM video */
+ this.videoWEBM = checkPlayType(elem, 'video/x-webm');
+
+ // Create an audio element.
+ elem = document.createElement('audio');
+
+ /** Can play audio OGG */
+ this.audioOGG = checkPlayType(elem, 'audio/ogg');
+
+ /** Can play audio MP3 */
+ this.audioMP3 = checkPlayType(elem, 'audio/mpeg');
+
+ /** Can play audio MP4 */
+ this.audioMP4 = checkPlayType(elem, 'audio/mp4');
+ };
+
+ /** Store all the playtypes for this browser */
+ if (!media.playTypes) {
+ media.playTypes = new media.compatibility();
+ }
+}(Drupal.media));
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function(media) {
+
+ /**
+ * @class This is a class used to keep track of flag states
+ * which is used to control the busy cursor, big play button, among other
+ * items in which multiple components can have an interest in hiding or
+ * showing a single element on the screen.
+ * <p>
+ * <strong>Usage:</strong>
+ * <pre><code>
+ * // Declare a flags variable.
+ * var flags = new Drupal.media.flags();
+ *
+ * // Set the flag based on two components interested in the flag.
+ * flags.setFlag("component1", true);
+ * flags.setFlag("component2", true);
+ *
+ * // Print out the value of the flags. ( Prints 3 )
+ * console.log(flags.flags);
+ *
+ * // Now unset a single components flag.
+ * flags.setFlag("component1", false);
+ *
+ * // Print out the value of the flags.
+ * console.log(flags.flags);
+ *
+ * // Unset the other components flag.
+ * flags.setFlag("component2", false);
+ *
+ * // Print out the value of the flags.
+ * console.log(flags.flags);
+ * </code></pre>
+ * </p>
+ */
+ media.flags = function() {
+
+ /** The flag. */
+ this.flag = 0;
+
+ /** Id map to reference id with the flag index. */
+ this.ids = {};
+
+ /** The number of flags. */
+ this.numFlags = 0;
+ };
+
+ /**
+ * Sets a flag based on boolean logic operators.
+ *
+ * @param {string} id The id of the controller interested in this flag.
+ * @param {boolean} value The value of this flag ( true or false ).
+ */
+ media.flags.prototype.setFlag = function(id, value) {
+
+ // Define this id if it isn't present.
+ if (!this.ids.hasOwnProperty(id)) {
+ this.ids[id] = this.numFlags;
+ this.numFlags++;
+ }
+
+ // Use binary operations to keep track of the flag state
+ if (value) {
+ this.flag |= (1 << this.ids[id]);
+ }
+ else {
+ this.flag &= ~(1 << this.ids[id]);
+ }
+ };
+}(Drupal.media));
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function(media) {
+
+ /**
+ * @class The base class for all plugins.
+ *
+ * @param {object} context The jQuery context.
+ * @param {object} options This components options.
+ */
+ media.plugin = function(context, options) {
+
+ // The media player.
+ this.player = null;
+
+ // Only call the constructor if we have a context.
+ if (context) {
+ this.construct();
+ }
+ };
+
+ /**
+ * The constructor which is called once the context is set.
+ * Any class deriving from the plugin class should place all context
+ * dependant functionality within this function instead of the standard
+ * constructor function since it is called on object derivation as well
+ * as object creation.
+ */
+ media.plugin.prototype.construct = function() {
+ };
+
+ /**
+ * Sets the current media player.
+ *
+ * @param {object} player The current media player.
+ */
+ media.plugin.prototype.setPlayer = function(player) {
+ this.player = player;
+ };
+}(Drupal.media));
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function($, media) {
+
+ /**
+ * @class Base class used to provide the display and options for any component
+ * deriving from this class. Components who derive are expected to provide
+ * the elements that they define by implementing the getElements method.
+ *
+ * @extends media.plugin
+ * @param {object} context The jQuery context this component resides.
+ * @param {object} options The options for this component.
+ */
+ media.display = function(context, options) {
+
+ if (context) {
+
+ // Set the display and options.
+ this.display = $(context);
+ this.options = options;
+
+ // Extend all display elements.
+ this.options.elements = this.options.elements || {};
+ $.extend(this.options.elements, this.getElements());
+ this.elements = this.options.elements;
+ }
+
+ // Derive from plugin
+ media.plugin.call(this, context, options);
+ };
+
+ // Define the prototype for all controllers.
+ media.display.prototype = new media.plugin();
+ media.display.prototype.constructor = media.display;
+
+ /**
+ * Returns all the jQuery elements that this component uses.
+ *
+ * @return {object} An object which defines all the jQuery elements that
+ * this component uses.
+ */
+ media.display.prototype.getElements = function() {
+ return {};
+ };
+
+ /**
+ * Returns if this component is valid and exists within the DOM.
+ *
+ * @return {boolean} TRUE if the plugin display is valid.
+ */
+ media.display.prototype.isValid = function() {
+ return (this.display.length > 0);
+ };
+}(jQuery, Drupal.media));
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function($, media) {
+
+ // Add a way to instanciate using jQuery prototype.
+ if (!$.fn.mediaplayer) {
+ $.fn.mediaplayer = function(options) {
+ return $(this).each(function() {
+ if (!media.player[$(this).selector]) {
+ new media.player($(this), options);
+ }
+ });
+ };
+ }
+
+ /**
+ * @class The core media player class which governs the media player
+ * functionality.
+ *
+ * <p><strong>Usage:</strong>
+ * <pre><code>
+ *
+ * // Create a media player.
+ * var player = $("#player").mediaplayer({
+ *
+ * });
+ *
+ * </code></pre>
+ * </p>
+ *
+ * @extends media.display
+ * @param {object} context The jQuery context.
+ * @param {object} options This components options.
+ */
+ media.player = function(context, options) {
+
+ // Make sure we provide default options...
+ options = $.extend({
+ id: 'player',
+ controller: 'default',
+ template: 'default',
+ volume: 80,
+ swfplayer: '',
+ wmode: 'transparent',
+ attributes: {},
+ settings: {}
+ }, options);
+
+ // Store this player instance.
+ media.player[options.id] = this;
+
+ // Derive from display
+ media.display.call(this, context, options);
+ };
+
+ /**
+ * Define the media player interface.
+ */
+ media.player.prototype = new media.display();
+ media.player.prototype.constructor = media.player;
+
+ /**
+ * @see media.plugin.construct
+ */
+ media.player.prototype.construct = function() {
+
+ // Call the media display constructor.
+ media.display.prototype.construct.call(this);
+
+ // Store the this pointer for callbacks.
+ var pluginInfo = {};
+ var plugin = null;
+ var pluginContext = null;
+ var i = media.plugins.length;
+ var _files = [];
+ var mediaSrc = null;
+
+ /** The current player. */
+ this.media = null;
+
+ /** All of the plugin objects. */
+ this.allPlugins = {};
+
+ // Iterate through all of our plugins and add them to our plugins array.
+ while (i--) {
+ pluginInfo = media.plugins[i];
+ if (pluginInfo.element) {
+ pluginContext = $(pluginInfo.element, this.display);
+ }
+ else {
+ pluginContext = this.display;
+ }
+ plugin = new pluginInfo.object(pluginContext, this.options);
+ this.addPlugin(pluginInfo.id, plugin);
+ }
+
+ /** Variable to store the current media player. */
+ this.currentPlayer = 'html5';
+
+ // Get the files involved...
+ if (this.elements.media) {
+ mediaSrc = this.elements.media.attr('src');
+ if (mediaSrc) {
+ _files.push({'path': mediaSrc});
+ }
+ $('source', this.elements.media).each(function() {
+ _files.push({
+ 'path': $(this).attr('src'),
+ 'mimetype': $(this).attr('type'),
+ 'codecs': $(this).attr('codecs')
+ });
+ });
+ }
+
+ // Add key events to the window.
+ $(window).bind('keyup', {obj: this}, function(event) {
+ // Escape out of fullscreen if they press ESC or Q.
+ var isFull = event.data.obj.display.hasClass('fullscreen');
+ if (isFull && (event.keyCode === 113 || event.keyCode === 27)) {
+ event.data.obj.display.removeClass('fullscreen');
+ }
+ });
+
+ // Now load these files.
+ this.load(_files);
+ };
+
+ /**
+ * Returns the full media player object.
+ * @param {array} files An array of files to chose from.
+ * @return {object} The best media file to play in the current browser.
+ */
+ media.player.prototype.getMediaFile = function(files) {
+ if (typeof files === 'string') {
+ return new media.file({'path': files});
+ }
+
+ if (files.path) {
+ return new media.file(files);
+ }
+
+ // Add the files and get the best player to play.
+ var i = files.length, bestPriority = 0, mFile = null, file = null;
+ while (i--) {
+ file = files[i];
+
+ // Get the media file object.
+ if (typeof file === 'string') {
+ file = new media.file({'path': file});
+ }
+ else {
+ file = new media.file(file);
+ }
+
+ // Determine the best file for this browser.
+ if (file.priority > bestPriority) {
+ mFile = file;
+ }
+ }
+
+ // Return the media file.
+ return mFile;
+ };
+
+ /**
+ * Load a set of files or a single file for the media player.
+ *
+ * @param {array} files An array of files to chose from to load.
+ */
+ media.player.prototype.load = function(files) {
+
+ // Get the best media file.
+ var mFile = this.getMediaFile(files), id = '', pClass = '';
+
+ // Only do something if we have a valid file.
+ if (mFile) {
+
+ // Only destroy if the current player is different than the new player.
+ if (!this.media || (mFile.player.toString() !== this.currentPlayer)) {
+
+ // Set the current media player.
+ this.currentPlayer = mFile.player.toString();
+
+ // Make sure the player has an option to cleanup.
+ if (this.media) {
+ this.media.destroy();
+ }
+
+ // Create a new media player for this file.
+ if (this.elements.display) {
+ pClass = media.players[mFile.player];
+ this.media = new pClass(this.elements.display, this.options, mFile);
+ }
+
+ // Iterate through all plugins and add the player to them.
+ for (id in this.allPlugins) {
+ if (this.allPlugins.hasOwnProperty(id)) {
+ this.allPlugins[id].setPlayer(this.media);
+ }
+ }
+ }
+
+ if (this.media) {
+ // Now load this media.
+ this.media.load(mFile);
+ }
+ }
+ };
+
+ /**
+ * Add a new plugin to the media player.
+ *
+ * @param {string} id The plugin ID.
+ * @param {object} plugin A new plugin object, derived from media.plugin.
+ */
+ media.player.prototype.addPlugin = function(id, plugin) {
+
+ // Only continue if the plugin exists.
+ if (plugin.isValid()) {
+
+ // Add to plugins.
+ this.allPlugins[id] = plugin;
+ }
+ };
+
+ /**
+ * Returns a plugin provided a plugin ID.
+ *
+ * @param {string} id The plugin ID to retrieve.
+ * @return {object} The plugin matching the provided ID.
+ */
+ media.player.prototype.getPlugin = function(id) {
+ return this.allPlugins[id];
+ };
+
+ /**
+ * Play the currently loaded media file. Use load first to load a
+ * media file into the media player.
+ */
+ media.player.prototype.play = function() {
+ if (this.media) {
+ this.media.play();
+ }
+ };
+
+ /**
+ * Pause the media.
+ */
+ media.player.prototype.pause = function() {
+ if (this.media) {
+ this.media.pause();
+ }
+ };
+
+ /**
+ * Stop the media.
+ */
+ media.player.prototype.stop = function() {
+ if (this.media) {
+ this.media.stop();
+ }
+ };
+
+ /**
+ * Seek the media to the provided position.
+ *
+ * @param {number} pos The position to seek. 0 to 1.
+ */
+ media.player.prototype.seek = function(pos) {
+ if (this.media) {
+ this.media.seek(pos);
+ }
+ };
+
+ /**
+ * Set the volume of the media being played.
+ *
+ * @param {number} vol The volume to set. 0 to 1.
+ */
+ media.player.prototype.setVolume = function(vol) {
+ if (this.media) {
+ this.media.setVolume(vol);
+ }
+ };
+
+ /**
+ * Get the current volume setting.
+ *
+ * @return {number} The current volume level. 0 to 1.
+ */
+ media.player.prototype.getVolume = function() {
+ return this.media ? this.media.getVolume() : 0;
+ };
+
+ /**
+ * Get the current media duration.
+ *
+ * @return {number} The current media duration.
+ */
+ media.player.prototype.getDuration = function() {
+ return this.media ? this.media.getDuration() : 0;
+ };
+}(jQuery, Drupal.media));
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function(media) {
+
+ /**
+ * @class A wrapper class used to provide all the data necessary to control an
+ * individual file within this media player.
+ *
+ * @param {object} file A media file object with minimal required information.
+ */
+ media.file = function(file) {
+ this.duration = file.duration || 0;
+ this.bytesTotal = file.bytesTotal || 0;
+ this.quality = file.quality || 0;
+ this.stream = file.stream || '';
+ this.path = file.path || '';
+ this.codecs = file.codecs || '';
+
+ // These should be provided, but just in case...
+ this.extension = file.extension || this.getFileExtension();
+ this.mimetype = file.mimetype || this.getMimeType();
+ this.type = file.type || this.getType();
+ this.player = file.player || this.getBestPlayer();
+ this.priority = file.priority || this.getPriority();
+ };
+
+ /**
+ * Returns the best player for the job.
+ *
+ * @return {string} The best player to play the media file.
+ */
+ media.file.prototype.getBestPlayer = function() {
+ var bestplayer = null, bestpriority = 0, _this = this;
+ jQuery.each(media.players, function(name, player) {
+ var priority = player.getPriority();
+ if (player.canPlay(_this) && (priority > bestpriority)) {
+ bestplayer = name;
+ bestpriority = priority;
+ }
+ });
+ return bestplayer;
+ };
+
+ /**
+ * The priority of this file is determined by the priority of the best
+ * player multiplied by the priority of the mimetype.
+ *
+ * @return {integer} The priority of the media file.
+ */
+ media.file.prototype.getPriority = function() {
+ var priority = 1;
+ if (this.player) {
+ priority = media.players[this.player].getPriority();
+ }
+ switch (this.mimetype) {
+ case 'video/x-webm':
+ return priority * 10;
+ case 'video/mp4':
+ case 'audio/mp4':
+ case 'audio/mpeg':
+ return priority * 9;
+ case 'video/ogg':
+ case 'audio/ogg':
+ case 'video/quicktime':
+ return priority * 8;
+ default:
+ return priority * 5;
+ }
+ };
+
+ /**
+ * Returns the file extension of the file path.
+ *
+ * @return {string} The file extension.
+ */
+ media.file.prototype.getFileExtension = function() {
+ return this.path.substring(this.path.lastIndexOf('.') + 1).toLowerCase();
+ };
+
+ /**
+ * Returns the proper mimetype based off of the extension.
+ *
+ * @return {string} The mimetype of the file based off of extension.
+ */
+ media.file.prototype.getMimeType = function() {
+ switch (this.extension) {
+ case 'mp4': case 'm4v': case 'flv': case 'f4v':
+ return 'video/mp4';
+ case'webm':
+ return 'video/x-webm';
+ case 'ogg': case 'ogv':
+ return 'video/ogg';
+ case '3g2':
+ return 'video/3gpp2';
+ case '3gpp':
+ case '3gp':
+ return 'video/3gpp';
+ case 'mov':
+ return 'video/quicktime';
+ case'swf':
+ return 'application/x-shockwave-flash';
+ case 'oga':
+ return 'audio/ogg';
+ case 'mp3':
+ return 'audio/mpeg';
+ case 'm4a': case 'f4a':
+ return 'audio/mp4';
+ case 'aac':
+ return 'audio/aac';
+ case 'wav':
+ return 'audio/vnd.wave';
+ case 'wma':
+ return 'audio/x-ms-wma';
+ default:
+ return 'unknown';
+ }
+ };
+
+ /**
+ * The type of media this is: video or audio.
+ *
+ * @return {string} "video" or "audio" based on what the type of media this
+ * is.
+ */
+ media.file.prototype.getType = function() {
+ switch (this.mimetype) {
+ case 'video/mp4':
+ case 'video/x-webm':
+ case 'video/ogg':
+ case 'video/3gpp2':
+ case 'video/3gpp':
+ case 'video/quicktime':
+ return 'video';
+ case 'audio/mp3':
+ case 'audio/mp4':
+ case 'audio/ogg':
+ return 'audio';
+ default:
+ return 'unknown';
+ }
+ };
+}(Drupal.media));
+
+
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function($, media) {
+
+ /** Define the playLoader object. */
+ media.playLoader = media.playLoader || {};
+
+ /**
+ * @class The play loader base class, which is used to control the busy
+ * cursor, big play button, and the opaque background which shows when the
+ * player is paused.
+ *
+ * @extends media.display
+ * @param {object} context The jQuery context.
+ * @param {object} options This components options.
+ */
+ media.playLoader.base = function(context, options) {
+
+ // Define the flags that control the busy cursor.
+ this.busy = new media.flags();
+
+ // Define the flags that control the big play button.
+ this.bigPlay = new media.flags();
+
+ // Derive from display
+ media.display.call(this, context, options);
+ };
+
+ // Define the prototype for all controllers.
+ media.playLoader.base.prototype = new media.display();
+ media.playLoader.base.prototype.constructor = media.playLoader.base;
+
+ /**
+ * @see media.plugin#construct
+ */
+ media.playLoader.base.prototype.construct = function() {
+
+ // Call the media plugin constructor.
+ media.display.prototype.construct.call(this);
+
+ // Trigger a play event when someone clicks on the controller.
+ if (this.elements.bigPlay) {
+ this.elements.bigPlay.bind('click', {obj: this}, function(event) {
+ event.preventDefault();
+ $(this).hide();
+ if (event.data.obj.player) {
+ event.data.obj.player.play();
+ }
+ });
+ }
+ };
+
+ /**
+ * Hide or show certain elements based on the state of the busy and big play
+ * button.
+ */
+ media.playLoader.base.prototype.checkVisibility = function() {
+
+ // Hide or show the busy cursor based on the flags.
+ if (this.busy.flag) {
+ this.elements.busy.show();
+ }
+ else {
+ this.elements.busy.hide();
+ }
+
+ // Hide or show the big play button based on the flags.
+ if (this.bigPlay.flag) {
+ this.elements.bigPlay.show();
+ }
+ else {
+ this.elements.bigPlay.hide();
+ }
+
+ // Show the control either flag is set.
+ if (this.bigPlay.flag || this.busy.flag) {
+ this.display.show();
+ }
+
+ // Hide the whole control if both flags are 0.
+ if (!this.bigPlay.flag && !this.busy.flag) {
+ this.display.hide();
+ }
+ };
+
+ /**
+ * @see media.plugin#setPlayer
+ */
+ media.playLoader.base.prototype.setPlayer = function(player) {
+ media.display.prototype.setPlayer.call(this, player);
+ var _this = this;
+ player.display.bind('loadstart', function(event) {
+ _this.busy.setFlag('media', true);
+ _this.bigPlay.setFlag('media', true);
+ _this.checkVisibility();
+ });
+ player.display.bind('waiting', function(event) {
+ _this.busy.setFlag('media', true);
+ _this.checkVisibility();
+ });
+ player.display.bind('loadedmetadata', function(event) {
+ _this.busy.setFlag('media', false);
+ _this.checkVisibility();
+ });
+ player.display.bind('loadeddata', function(event) {
+ _this.busy.setFlag('media', false);
+ _this.checkVisibility();
+ });
+ player.display.bind('playing', function(event) {
+ _this.busy.setFlag('media', false);
+ _this.bigPlay.setFlag('media', false);
+ _this.checkVisibility();
+ });
+ player.display.bind('pause', function(event) {
+ _this.bigPlay.setFlag('media', true);
+ _this.checkVisibility();
+ });
+ };
+}(jQuery, Drupal.media));
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function($, media) {
+
+ /** All the media player implementations */
+ media.players = media.players || {};
+
+ /**
+ * @class The base media player class where all media players derive from.
+ *
+ * @extends media.display
+ * @param {object} context The jQuery context.
+ * @param {object} options This components options.
+ */
+ media.players.base = function(context, options, mediaFile) {
+
+ /** The currently loaded media file. */
+ this.mediaFile = mediaFile;
+
+ // Derive from display
+ media.display.call(this, context, options);
+ };
+
+ // Extend the display prototype.
+ media.players.base.prototype = new media.display();
+ media.players.base.prototype.constructor = media.players.base;
+
+ /**
+ * Get the priority of this media player.
+ *
+ * @return {number} The priority of this media player.
+ */
+ media.players.base.getPriority = function() {
+ return 0;
+ };
+
+ /**
+ * Determine if we can play the media file.
+ *
+ * @param {object} file A {@link media.file} object.
+ */
+ media.players.base.canPlay = function(file) {
+ return false;
+ };
+
+ /**
+ * @see media.plugin.construct
+ */
+ media.players.base.prototype.construct = function() {
+
+ // Call the media display constructor.
+ media.display.prototype.construct.call(this);
+
+ // Get the player display object.
+ if (!this.playerFound()) {
+
+ // Cleanup some events and code.
+ this.display.unbind();
+
+ // Remove the media element if found
+ if (this.elements.media) {
+ this.elements.media.remove();
+ }
+
+ // Create a new media player element.
+ this.display.html(this.create());
+ }
+
+ // Get the player object...
+ this.player = this.getPlayer();
+
+ /**
+ * Trigger a media event.
+ *
+ * @param {string} type The event type.
+ * @param {object} data The event data object.
+ */
+ this.trigger = function(type, data) {
+ this.display.trigger(type, data);
+ };
+
+ this.duration = 0;
+ this.currentTime = 0;
+ };
+
+ /**
+ * Returns if the media player is already within the DOM.
+ *
+ * @return {boolean} TRUE - if the player is in the DOM, FALSE otherwise.
+ */
+ media.players.base.prototype.playerFound = function() {
+ return false;
+ };
+
+ /**
+ * Creates the media player and inserts it in the DOM.
+ *
+ * @return {object} The media player entity.
+ */
+ media.players.base.prototype.create = function() {
+ return null;
+ };
+
+ /**
+ * Returns the media player object.
+ *
+ * @return {object} The media player object.
+ */
+ media.players.base.prototype.getPlayer = function() {
+ return null;
+ };
+
+ /**
+ * Destroy the media player instance from the DOM.
+ */
+ media.players.base.prototype.destroy = function() {
+ };
+
+ /**
+ * Loads a new media player.
+ *
+ * @param {object} file A {@link media.file} object.
+ */
+ media.players.base.prototype.load = function(file) {
+
+ // Store the media file for future lookup.
+ this.mediaFile = file;
+ };
+
+ /**
+ * Play the loaded media file.
+ */
+ media.players.base.prototype.play = function() {
+ };
+
+ /**
+ * Pause the loaded media file.
+ */
+ media.players.base.prototype.pause = function() {
+ };
+
+ /**
+ * Stop the loaded media file.
+ */
+ media.players.base.prototype.stop = function() {
+ };
+
+ /**
+ * Seek the loaded media.
+ *
+ * @param {number} pos The position to seek the media. 0 to 1.
+ */
+ media.players.base.prototype.seek = function(pos) {
+
+ };
+
+ /**
+ * Set the volume of the loaded media.
+ *
+ * @param {number} vol The volume to set the media. 0 to 1.
+ */
+ media.players.base.prototype.setVolume = function(vol) {
+ this.trigger('volumeupdate', vol);
+ };
+
+ /**
+ * Get the volume from the loaded media.
+ *
+ * @return {number} The volume of the media; 0 to 1.
+ */
+ media.players.base.prototype.getVolume = function() {
+ return 0;
+ };
+
+ /**
+ * Return the duration of the loaded media.
+ *
+ * @return {number} The duration of the loaded media.
+ */
+ media.players.base.prototype.getDuration = function() {
+ return 0;
+ };
+}(jQuery, Drupal.media));
+
+
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function($, media) {
+
+ /** All the media player implementations */
+ media.players = media.players || {};
+
+ /**
+ * @class The HTML5 media player implementation.
+ *
+ * @extends media.display
+ * @param {object} context The jQuery context.
+ * @param {object} options This components options.
+ */
+ media.players.html5 = function(context, options, mediaFile) {
+
+ // Derive players base.
+ media.players.base.call(this, context, options, mediaFile);
+ };
+
+ // Define the prototype.
+ media.players.html5.prototype = new media.players.base();
+ media.players.html5.prototype.constructor = media.players.html5;
+
+ /**
+ * @see media.players.base#getPriority
+ */
+ media.players.html5.getPriority = function() {
+ return 10;
+ };
+
+ /**
+ * @see media.players.base#canPlay
+ */
+ media.players.html5.canPlay = function(file) {
+ switch (file.mimetype) {
+ case 'video/ogg':
+ return media.playTypes.videoOGG;
+ case 'video/mp4':
+ return media.playTypes.videoH264;
+ case 'video/x-webm':
+ return media.playTypes.videoWEBM;
+ case 'audio/ogg':
+ return media.playTypes.audioOGG;
+ case 'audio/mpeg':
+ return media.playTypes.audioMP3;
+ case 'audio/mp4':
+ return media.playTypes.audioMP4;
+ default:
+ return false;
+ }
+ };
+
+ /**
+ * @see media.plugin.construct
+ */
+ media.players.html5.prototype.construct = function() {
+
+ // Call base constructor.
+ media.players.base.prototype.construct.call(this);
+
+ // See if we are loaded.
+ this.loaded = false;
+
+ // Store the this pointer...
+ var _this = this;
+
+ // For the HTML5 player, we will just pass events along...
+ if (this.player) {
+ this.player.addEventListener('abort', function() {
+ _this.trigger('abort');
+ }, true);
+ this.player.addEventListener('loadstart', function() {
+ _this.trigger('loadstart');
+ }, true);
+ this.player.addEventListener('loadeddata', function() {
+ _this.trigger('loadeddata');
+ }, true);
+ this.player.addEventListener('loadedmetadata', function() {
+ _this.trigger('loadedmetadata');
+ }, true);
+ this.player.addEventListener('canplaythrough', function() {
+ _this.trigger('canplaythrough');
+ }, true);
+ this.player.addEventListener('ended', function() {
+ _this.trigger('ended');
+ }, true);
+ this.player.addEventListener('pause', function() {
+ _this.trigger('pause');
+ }, true);
+ this.player.addEventListener('play', function() {
+ _this.trigger('play');
+ }, true);
+ this.player.addEventListener('playing', function() {
+ _this.trigger('playing');
+ }, true);
+ this.player.addEventListener('error', function() {
+ _this.trigger('error');
+ }, true);
+ this.player.addEventListener('waiting', function() {
+ _this.trigger('waiting');
+ }, true);
+ this.player.addEventListener('timeupdate', function(event) {
+ var dur = this.duration;
+ var cTime = this.currentTime;
+ _this.duration = dur;
+ _this.currentTime = cTime;
+ _this.trigger('timeupdate', {currentTime: cTime, duration: dur});
+ }, true);
+ this.player.addEventListener('durationchange', function() {
+ _this.duration = this.duration;
+ _this.trigger('durationchange', {duration: this.duration});
+ }, true);
+ this.player.addEventListener('progress', function(event) {
+ _this.trigger('progress', {loaded: event.loaded, total: event.total});
+ }, true);
+
+ if (this.autoBuffer()) {
+ this.player.autobuffer = true;
+ } else {
+ this.player.autobuffer = false;
+ this.player.preload = 'none';
+ }
+ }
+ };
+
+ // Determine if this player is able to autobuffer.
+ media.players.html5.prototype.autoBuffer = function() {
+ var preload = this.player.preload !== 'none';
+ if (typeof this.player.hasAttribute === 'function') {
+ return this.player.hasAttribute('preload') && preload;
+ }
+ else {
+ return false;
+ }
+ };
+
+ /**
+ * @see media.players.base#playerFound
+ */
+ media.players.html5.prototype.playerFound = function() {
+ return (this.display.find(this.mediaFile.type).length > 0);
+ };
+
+ /**
+ * @see media.players.base#create
+ */
+ media.players.html5.prototype.create = function() {
+ var element = document.createElement(this.mediaFile.type), attribute = '';
+ for (attribute in this.options.attributes) {
+ if (this.options.attributes.hasOwnProperty(attribute)) {
+ element.setAttribute(attribute, this.options.attributes[attribute]);
+ }
+ }
+ return element;
+ };
+
+ /**
+ * @see media.players.base#getPlayer
+ */
+ media.players.html5.prototype.getPlayer = function() {
+ return this.options.elements.media.eq(0)[0];
+ };
+
+ /**
+ * @see media.players.base#load
+ */
+ media.players.html5.prototype.load = function(file) {
+ // Always call the base first on load...
+ media.players.base.prototype.load.call(this, file);
+
+ if (this.loaded) {
+ // Change the source...
+ var code = '<source src="' + file.path + '" ';
+ code += 'type="' + file.mimetype + '"';
+ code += file.codecs ? ' codecs="' + file.path + '">' : '>';
+ this.options.elements.player.attr('src', '').empty().html(code);
+ }
+
+ // Set the loaded flag.
+ this.loaded = true;
+ };
+
+ /**
+ * @see media.players.base#play
+ */
+ media.players.html5.prototype.play = function() {
+ media.players.base.prototype.play.call(this);
+ this.player.play();
+ };
+
+ /**
+ * @see media.players.base#pause
+ */
+ media.players.html5.prototype.pause = function() {
+ media.players.base.prototype.pause.call(this);
+ this.player.pause();
+ };
+
+ /**
+ * @see media.players.base#stop
+ */
+ media.players.html5.prototype.stop = function() {
+ media.players.base.prototype.stop.call(this);
+ this.media.pause();
+ this.player.src = '';
+ };
+
+ /**
+ * @see media.players.base#seek
+ */
+ media.players.html5.prototype.seek = function(pos) {
+ media.players.base.prototype.seek.call(this, pos);
+ this.player.currentTime = pos;
+ };
+
+ /**
+ * @see media.players.base#setVolume
+ */
+ media.players.html5.prototype.setVolume = function(vol) {
+ media.players.base.prototype.setVolume.call(this, vol);
+ this.player.volume = vol;
+ };
+
+ /**
+ * @see media.players.base#getVolume
+ */
+ media.players.html5.prototype.getVolume = function() {
+ return this.player.volume;
+ };
+
+ /**
+ * @see media.players.base#getDuration
+ */
+ media.players.html5.prototype.getDuration = function() {
+ var dur = this.player.duration;
+ return (dur === Infinity) ? 0 : dur;
+ };
+}(jQuery, Drupal.media));
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function($, media) {
+
+ /** All the media player implementations */
+ media.players = media.players || {};
+
+ /**
+ * @class The Flash media player class to control the flash fallback.
+ *
+ * @extends media.display
+ * @param {object} context The jQuery context.
+ * @param {object} options This components options.
+ */
+ media.players.flash = function(context, options, mediaFile) {
+
+ this.durationInterval = null;
+ this.mediaInterval = null;
+ this.duration = 0;
+ this.ready = false;
+
+ // Derive from players base.
+ media.players.base.call(this, context, options, mediaFile);
+ };
+
+ // Define the prototype.
+ media.players.flash.prototype = new media.players.base();
+ media.players.flash.prototype.constructor = media.players.flash;
+
+ /**
+ * @see media.players.base#getPriority
+ */
+ media.players.flash.getPriority = function() {
+ return 0;
+ };
+
+ /**
+ * @see media.players.base#canPlay
+ */
+ media.players.flash.canPlay = function(file) {
+ return false;
+ };
+
+ /**
+ * API to return the Flash player code provided params.
+ *
+ * @param {object} params The params used to populate the Flash code.
+ */
+ media.players.flash.getFlash = function(params) {
+ // Get the protocol.
+ var protocol = window.location.protocol;
+ var element = null;
+ var embed = null;
+ var paramKey = '';
+ var flashParams = {};
+ var param = null;
+
+ if (protocol.charAt(protocol.length - 1) === ':') {
+ protocol = protocol.substring(0, protocol.length - 1);
+ }
+
+ // Create an object element.
+ element = document.createElement('object');
+ element.setAttribute('width', params.width);
+ element.setAttribute('height', params.height);
+ element.setAttribute('id', params.id);
+ element.setAttribute('name', params.id);
+ element.setAttribute('playerType', params.playerType);
+
+ // Setup a params array to make the param additions eaiser.
+ flashParams = {
+ 'allowScriptAccess': 'always',
+ 'allowfullscreen': 'true',
+ 'movie': params.swf,
+ 'wmode': params.wmode,
+ 'quality': 'high',
+ 'FlashVars': $.param(params.flashvars)
+ };
+
+ // Add the parameters.
+ for (paramKey in flashParams) {
+ if (flashParams.hasOwnProperty(paramKey)) {
+ param = document.createElement('param');
+ param.setAttribute('name', paramKey);
+ param.setAttribute('value', flashParams[paramKey]);
+ element.appendChild(param);
+ }
+ }
+
+ // Add the embed element.
+ embed = document.createElement('embed');
+ for (paramKey in flashParams) {
+ if (flashParams.hasOwnProperty(paramKey)) {
+ paramKey = (paramKey === 'movie') ? 'src' : paramKey;
+ embed.setAttribute(paramKey, flashParams[paramKey]);
+ }
+ }
+
+ embed.setAttribute('width', params.width);
+ embed.setAttribute('height', params.height);
+ embed.setAttribute('id', params.id);
+ embed.setAttribute('name', params.id);
+ embed.setAttribute('swLiveConnect', 'true');
+ embed.setAttribute('type', 'application/x-shockwave-flash');
+ element.appendChild(embed);
+ return element;
+ };
+
+ /**
+ * Called when the player is ready.
+ */
+ media.players.flash.prototype.onReady = function() {
+ var _this = this;
+ this.ready = true;
+ this.trigger('loadstart');
+
+ // Perform a check for the duration every second until it shows up.
+ this.durationInterval = setInterval(function() {
+ if (_this.getDuration()) {
+ clearInterval(_this.durationInterval);
+ _this.trigger('durationchange', {duration: _this.getDuration()});
+ }
+ }, 1000);
+ };
+
+ /**
+ * Should be called when the media is playing.
+ */
+ media.players.flash.prototype.onPlaying = function() {
+ var _this = this;
+ this.trigger('playing');
+ this.mediaInterval = setInterval(function() {
+ var cTime = _this.getCurrentTime();
+ var dur = _this.getDuration();
+ var data = {currentTime: cTime, duration: dur};
+ _this.trigger('timeupdate', data);
+ }, 1000);
+ };
+
+ /**
+ * Should be called when the media is paused.
+ */
+ media.players.flash.prototype.onPaused = function() {
+ this.trigger('pause');
+ clearInterval(this.mediaInterval);
+ };
+
+ /**
+ * Should be called when the meta data has finished loading.
+ */
+ media.players.flash.prototype.onMeta = function() {
+ clearInterval(this.durationInterval);
+ this.trigger('loadeddata');
+ this.trigger('loadedmetadata');
+ this.trigger('durationchange', {duration: this.getDuration()});
+ };
+
+ /**
+ * Reset the flash player variables.
+ */
+ media.players.flash.prototype.reset = function() {
+ this.ready = false;
+ this.duration = 0;
+ };
+
+ /**
+ * @see media.players.base#destroy
+ */
+ media.players.flash.prototype.destroy = function() {
+ this.reset();
+ };
+
+ /**
+ * @see media.players.base#playerFound
+ */
+ media.players.flash.prototype.playerFound = function() {
+ return (this.display.find('object[playerType="flash"]').length > 0);
+ };
+
+ /**
+ * @see media.players.base#create
+ */
+ media.players.flash.prototype.create = function() {
+ // Reset the variables.
+ this.reset();
+ return null;
+ };
+
+ /**
+ * @see media.players.base#getPlayer
+ */
+ media.players.flash.prototype.getPlayer = function() {
+ // IE needs the object, everyone else just needs embed.
+ var object = $.browser.msie ? 'object' : 'embed';
+ return $(object, this.display).eq(0)[0];
+ };
+
+ /**
+ * @see media.players.base#load
+ */
+ media.players.flash.prototype.load = function(file) {
+ this.duration = 0;
+ media.players.base.prototype.load.call(this, file);
+ };
+
+ /**
+ * Return the player time duration.
+ *
+ * @return {int} The player duration.
+ */
+ media.players.flash.prototype.getPlayerDuration = function() {
+ return 0;
+ };
+
+ /**
+ * @see media.players.base#getDuration
+ */
+ media.players.flash.prototype.getDuration = function() {
+
+ // Make sure to cache the duration since it is called often.
+ if (this.duration) {
+ return this.duration;
+ }
+ else if (this.isReady()) {
+ this.duration = this.getPlayerDuration();
+ return this.duration;
+ }
+ else {
+ return media.players.base.prototype.getDuration.call(this);
+ }
+ };
+
+ /**
+ * @see media.players.base#isReady
+ */
+ media.players.flash.prototype.isReady = function() {
+ return (this.player && this.ready);
+ };
+}(jQuery, Drupal.media));
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function($, media) {
+
+ /** All the media player implementations */
+ media.players = media.players || {};
+
+ /**
+ * @class The Flash media player class to control the flash fallback.
+ *
+ * @extends media.display
+ * @param {object} context The jQuery context.
+ * @param {object} options This components options.
+ */
+ media.players.minplayer = function(context, options, mediaFile) {
+
+ // Called when the flash provides a media update.
+ this.onMediaUpdate = function(eventType) {
+ if (this.ready) {
+ switch (eventType) {
+ case 'mediaMeta':
+ media.players.flash.prototype.onMeta.call(this);
+ break;
+ case 'mediaPlaying':
+ media.players.flash.prototype.onPlaying.call(this);
+ break;
+ case 'mediaPaused':
+ media.players.flash.prototype.onPaused.call(this);
+ break;
+ }
+ }
+ };
+
+ // Derive from players flash.
+ media.players.flash.call(this, context, options, mediaFile);
+ };
+
+ // Define the prototype.
+ media.players.minplayer.prototype = new media.players.flash();
+ media.players.minplayer.prototype.constructor = media.players.minplayer;
+
+ window.onFlashPlayerReady = function(id) {
+ if (media.player[id]) {
+ media.player[id].media.onReady();
+ }
+ };
+
+ window.onFlashPlayerUpdate = function(id, eventType) {
+ if (media.player[id]) {
+ media.player[id].media.onMediaUpdate(eventType);
+ }
+ };
+
+ var debugConsole = console || {log: function(data) {}};
+ window.onFlashPlayerDebug = function(debug) {
+ debugConsole.log(debug);
+ };
+
+ /**
+ * @see media.players.base#getPriority
+ */
+ media.players.minplayer.getPriority = function() {
+ return 1;
+ };
+
+ /**
+ * @see media.players.base#canPlay
+ */
+ media.players.minplayer.canPlay = function(file) {
+ switch (file.mimetype) {
+ case 'video/mp4':
+ case 'video/x-webm':
+ case 'video/quicktime':
+ case 'video/3gpp2':
+ case 'video/3gpp':
+ case 'application/x-shockwave-flash':
+ case 'audio/mpeg':
+ case 'audio/mp4':
+ case 'audio/aac':
+ case 'audio/vnd.wave':
+ case 'audio/x-ms-wma':
+ return true;
+
+ default:
+ return false;
+ }
+ };
+
+ /**
+ * @see media.players.base#create
+ */
+ media.players.minplayer.prototype.create = function() {
+
+ media.players.flash.prototype.create.call(this);
+
+ // The flash variables for this flash player.
+ var flashVars = {
+ 'id': this.options.id,
+ 'debug': this.options.settings.debug,
+ 'config': 'nocontrols',
+ 'file': this.mediaFile.path,
+ 'autostart': this.options.settings.autoplay
+ };
+
+ // Return a flash media player object.
+ return media.players.flash.getFlash({
+ swf: this.options.swfplayer,
+ id: this.options.id + '_player',
+ playerType: 'flash',
+ width: this.options.settings.width,
+ height: '100%',
+ flashvars: flashVars,
+ wmode: this.options.wmode
+ });
+ };
+
+ /**
+ * @see media.players.base#load
+ */
+ media.players.minplayer.prototype.load = function(file) {
+ media.players.flash.prototype.load.call(this, file);
+ if (this.isReady()) {
+ this.player.loadMedia(this.mediaFile.path, this.mediaFile.stream);
+ }
+ };
+
+ /**
+ * @see media.players.base#play
+ */
+ media.players.minplayer.prototype.play = function() {
+ media.players.flash.prototype.play.call(this);
+ if (this.isReady()) {
+ this.player.playMedia();
+ }
+ };
+
+ /**
+ * @see media.players.base#pause
+ */
+ media.players.minplayer.prototype.pause = function() {
+ media.players.flash.prototype.pause.call(this);
+ if (this.isReady()) {
+ this.player.pauseMedia();
+ }
+ };
+
+ /**
+ * @see media.players.base#stop
+ */
+ media.players.minplayer.prototype.stop = function() {
+ media.players.flash.prototype.stop.call(this);
+ if (this.isReady()) {
+ this.player.stopMedia();
+ }
+ };
+
+ /**
+ * @see media.players.base#seek
+ */
+ media.players.minplayer.prototype.seek = function(pos) {
+ media.players.flash.prototype.seek.call(this, pos);
+ if (this.isReady()) {
+ this.player.seekMedia(pos);
+ }
+ };
+
+ /**
+ * @see media.players.base#setVolume
+ */
+ media.players.minplayer.prototype.setVolume = function(vol) {
+ media.players.flash.prototype.setVolume.call(this, vol);
+ if (this.isReady()) {
+ this.player.setVolume(vol);
+ }
+ };
+
+ /**
+ * @see media.players.base#getVolume
+ */
+ media.players.minplayer.prototype.getVolume = function() {
+ if (this.isReady()) {
+ return this.player.getVolume();
+ }
+ else {
+ return media.players.flash.prototype.getVolume.call(this);
+ }
+ };
+
+ /**
+ * @see media.players.flash#getPlayerDuration
+ */
+ media.players.minplayer.prototype.getPlayerDuration = function() {
+ return this.isReady() ? this.player.getDuration() : 0;
+ };
+
+ /**
+ * @see media.players.base#getCurrentTime
+ */
+ media.players.minplayer.prototype.getCurrentTime = function() {
+ return this.isReady() ? this.player.getCurrentTime() : 0;
+ };
+
+ /**
+ * @see media.players.base#getBytesLoaded
+ */
+ media.players.minplayer.prototype.getBytesLoaded = function() {
+ return this.isReady() ? this.player.getMediaBytesLoaded() : 0;
+ };
+
+ /**
+ * @see media.players.base#getBytesTotal
+ */
+ media.players.minplayer.prototype.getBytesTotal = function() {
+ return this.isReady() ? this.player.getMediaBytesTotal() : 0;
+ };
+}(jQuery, Drupal.media));
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function($, media) {
+
+ /** All the media player implementations */
+ media.players = media.players || {};
+
+ /**
+ * @class The Flash media player class to control the flash fallback.
+ *
+ * @extends media.display
+ * @param {object} context The jQuery context.
+ * @param {object} options This components options.
+ */
+ media.players.youtube = function(context, options, mediaFile) {
+
+ // Derive from players flash.
+ media.players.flash.call(this, context, options, mediaFile);
+
+ /** The quality of the YouTube stream. */
+ this.quality = 'default';
+ };
+
+ // Define the prototype.
+ media.players.youtube.prototype = new media.players.flash();
+ media.players.youtube.prototype.constructor = media.players.youtube;
+
+ // Called when the YouTube player is ready.
+ window.onYouTubePlayerReady = function(id) {
+ if (media.player[id]) {
+ media.player[id].media.onReady();
+ }
+ };
+
+ /**
+ * @see media.plugin.construct
+ */
+ media.players.youtube.prototype.construct = function() {
+
+ // Call flash constructor.
+ media.players.flash.prototype.construct.call(this);
+
+ // Translates the player state for the YouTube API player.
+ this.getPlayerState = function(playerState) {
+ switch (playerState) {
+ case 5:
+ return 'ready';
+ case 3:
+ return 'waiting';
+ case 2:
+ return 'pause';
+ case 1:
+ return 'play';
+ case 0:
+ return 'ended';
+ case -1:
+ return 'abort';
+ default:
+ return 'unknown';
+ }
+ };
+
+ // Create our callback functions.
+ var _this = this;
+ window[this.options.id + 'StateChange'] = function(newState) {
+ _this.trigger(_this.getPlayerState(newState));
+ };
+
+ window[this.options.id + 'PlayerError'] = function(errorCode) {
+ _this.trigger('error', errorCode);
+ };
+
+ window[this.options.id + 'QualityChange'] = function(newQuality) {
+ _this.quality = newQuality;
+ };
+
+ // Add our event listeners.
+ if (this.player) {
+ var onStateChange = this.options.id + 'StateChange';
+ var onError = this.options.id + 'PlayerError';
+ var onQuality = this.options.id + 'QualityChange';
+ this.player.addEventListener('onStateChange', onStateChange);
+ this.player.addEventListener('onError', onError);
+ this.player.addEventListener('onPlaybackQualityChange', onQuality);
+ }
+ };
+
+ /**
+ * @see media.players.base#getPriority
+ */
+ media.players.youtube.getPriority = function() {
+ return 10;
+ };
+
+ /**
+ * @see media.players.base#canPlay
+ */
+ media.players.youtube.canPlay = function(file) {
+
+ // Check for the mimetype for youtube.
+ if (file.mimetype === 'video/youtube') {
+ return true;
+ }
+
+ // If the path is a YouTube path, then return true.
+ return (file.path.search(/^http(s)?\:\/\/(www\.)?youtube\.com/i) === 0);
+ };
+
+ /**
+ * @see media.players.base#create
+ */
+ media.players.youtube.prototype.create = function() {
+
+ media.players.base.prototype.flash.call(this);
+
+ // The flash variables for this flash player.
+ var flashVars = {
+ 'file': this.mediaFile.path,
+ 'autostart': this.options.settings.autoplay
+ };
+
+ // Return a flash media player object.
+ var rand = Math.floor(Math.random() * 1000000);
+ var flashPlayer = 'http://www.youtube.com/apiplayer?rand=' + rand;
+ flashPlayer += '&amp;version=3&amp;enablejsapi=1&amp;playerapiid=';
+ flashPlayer += this.options.id;
+ return media.players.flash.getFlash({
+ swf: flashPlayer,
+ id: this.options.id + '_player',
+ playerType: 'flash',
+ width: this.options.settings.width,
+ height: '100%',
+ flashvars: flashVars,
+ wmode: this.options.wmode
+ });
+ };
+
+ /**
+ * Return the Regular Expression to find a YouTube ID.
+ *
+ * @return {RegEx} A regular expression to find a YouTube ID.
+ */
+ media.players.youtube.prototype.regex = function() {
+ return /^http[s]?\:\/\/(www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9]+)/i;
+ };
+
+ /**
+ * @see media.players.base#load
+ */
+ media.players.youtube.prototype.load = function(file) {
+ media.players.flash.prototype.load.call(this, file);
+ if (this.isReady()) {
+ var regex = this.regex();
+ var id = '';
+ if (this.mediaFile.path.search(regex) === 0) {
+ id = this.mediaFile.path.replace(regex, '$2');
+ }
+ else {
+ id = this.mediaFile.path;
+ }
+ this.player.loadVideoById(id, 0, this.quality);
+ }
+ };
+
+ /**
+ * @see media.players.base#play
+ */
+ media.players.youtube.prototype.play = function() {
+ media.players.flash.prototype.play.call(this);
+ if (this.isReady()) {
+ this.player.playVideo();
+ }
+ };
+
+ /**
+ * @see media.players.base#pause
+ */
+ media.players.youtube.prototype.pause = function() {
+ media.players.flash.prototype.pause.call(this);
+ if (this.isReady()) {
+ this.player.pauseVideo();
+ }
+ };
+
+ /**
+ * @see media.players.base#stop
+ */
+ media.players.youtube.prototype.stop = function() {
+ media.players.flash.prototype.stop.call(this);
+ if (this.isReady()) {
+ this.player.stopVideo();
+ }
+ };
+
+ /**
+ * @see media.players.base#seek
+ */
+ media.players.youtube.prototype.seek = function(pos) {
+ media.players.flash.prototype.seek.call(this, pos);
+ if (this.isReady()) {
+ this.player.seekTo(pos, true);
+ }
+ };
+
+ /**
+ * @see media.players.base#setVolume
+ */
+ media.players.youtube.prototype.setVolume = function(vol) {
+ media.players.flash.prototype.setVolume.call(this, vol);
+ if (this.isReady()) {
+ this.player.setVolume(vol * 100);
+ }
+ };
+
+ /**
+ * @see media.players.base#getVolume
+ */
+ media.players.youtube.prototype.getVolume = function() {
+ if (this.isReady()) {
+ return (this.player.getVolume() / 100);
+ }
+ else {
+ return media.players.flash.prototype.getVolume.call(this);
+ }
+ };
+
+ /**
+ * @see media.players.flash#getPlayerDuration
+ */
+ media.players.youtube.prototype.getPlayerDuration = function() {
+ return this.isReady() ? this.player.getDuration() : 0;
+ };
+
+ /**
+ * @see media.players.base#getCurrentTime
+ */
+ media.players.youtube.prototype.getCurrentTime = function() {
+ return this.isReady() ? this.player.getCurrentTime() : 0;
+ };
+
+ /**
+ * @see media.players.base#getBytesLoaded
+ */
+ media.players.youtube.prototype.getBytesLoaded = function() {
+ return this.isReady() ? this.player.getVideoBytesLoaded() : 0;
+ };
+
+ /**
+ * @see media.players.base#getBytesTotal
+ */
+ media.players.youtube.prototype.getBytesTotal = function() {
+ return this.isReady() ? this.player.getVideoBytesTotal() : 0;
+ };
+}(jQuery, Drupal.media));
+/** The Drupal namespace. */
+Drupal.media = Drupal.media || {};
+(function($, media) {
+
+ /** Define the controllers object. */
+ media.controllers = media.controllers || {};
+
+ /**
+ * @class This is the base media controller. Other controllers can derive
+ * from the base and either build on top of it or simply define the elements
+ * that this base controller uses.
+ *
+ * @extends media.display
+ * @param {object} context The jQuery context.
+ * @param {object} options This components options.
+ */
+ media.controllers.base = function(context, options) {
+
+ // Derive from display
+ media.display.call(this, context, options);
+ }
+
+ // Define the prototype for all controllers.
+ var controllersBase = media.controllers.base;
+ media.controllers.base.prototype = new media.display();
+ media.controllers.base.prototype.constructor = media.controllers.base;
+
+ /**
+ * A static function that will format a time value into a string time format.
+ *
+ * @param {integer} time An integer value of time.
+ * @return {string} A string representation of the time.
+ */
+ media.formatTime = function(time) {
+ time = time || 0;
+ var seconds = 0, minutes = 0, hour = 0, timeString = '';
+
+ hour = Math.floor(time / 3600);
+ time -= (hour * 3600);
+ minutes = Math.floor(time / 60);
+ time -= (minutes * 60);
+ seconds = Math.floor(time % 60);
+
+ if (hour) {
+ timeString += String(hour);
+ timeString += ':';
+ }
+
+ timeString += (minutes >= 10) ? String(minutes) : ('0' + String(minutes));
+ timeString += ':';
+ timeString += (seconds >= 10) ? String(seconds) : ('0' + String(seconds));
+ return {time: timeString, units: ''};
+ };
+
+ /**
+ * @see media.display#getElements
+ */
+ media.controllers.base.prototype.getElements = function() {
+ var elements = media.display.prototype.getElements.call(this);
+ return $.extend(elements, {
+ play: null,
+ pause: null,
+ fullscreen: null,
+ seek: null,
+ volume: null,
+ timer: null
+ });
+ };
+
+ /**
+ * @see media.plugin#construct
+ */
+ media.controllers.base.prototype.construct = function() {
+
+ // Call the media plugin constructor.
+ media.display.prototype.construct.call(this);
+
+ // Play or pause the player.
+ function playPause(controller, state) {
+ var type = state ? 'play' : 'pause';
+ controller.display.trigger(type);
+ controller.setPlayPause(state);
+ if (controller.player) {
+ controller.player[type]();
+ }
+ }
+
+ // Trigger the controller events.
+ if (this.elements.play) {
+ this.elements.play.bind('click', {obj: this}, function(event) {
+ event.preventDefault();
+ playPause(event.data.obj, true);
+ });
+ }
+
+ if (this.elements.pause) {
+ this.elements.pause.bind('click', {obj: this}, function(event) {
+ event.preventDefault();
+ playPause(event.data.obj, false);
+ });
+ }
+
+ // Fullscreen button.
+ var _this = this, sliderOptions = {};
+ if (this.elements.fullscreen) {
+ this.elements.fullscreen.click(function() {
+ var isFull = _this.elements.player.hasClass('fullscreen');
+ if (isFull) {
+ _this.elements.player.removeClass('fullscreen');
+ }
+ else {
+ _this.elements.player.addClass('fullscreen');