1 /** The minplayer namespace. */
  2 var minplayer = minplayer || {};
  3 
  4 /** All the media player implementations */
  5 minplayer.players = minplayer.players || {};
  6 
  7 /**
  8  * @constructor
  9  * @extends minplayer.display
 10  * @class The Flash media player class to control the flash fallback.
 11  *
 12  * @param {object} context The jQuery context.
 13  * @param {object} options This components options.
 14  */
 15 minplayer.players.flash = function(context, options) {
 16 
 17   // Derive from players base.
 18   minplayer.players.base.call(this, context, options);
 19 };
 20 
 21 /** Derive from minplayer.players.base. */
 22 minplayer.players.flash.prototype = new minplayer.players.base();
 23 
 24 /** Reset the constructor. */
 25 minplayer.players.flash.prototype.constructor = minplayer.players.flash;
 26 
 27 /**
 28  * @see minplayer.players.base#getPriority
 29  * @return {number} The priority of this media player.
 30  */
 31 minplayer.players.flash.getPriority = function() {
 32   return 0;
 33 };
 34 
 35 /**
 36  * @see minplayer.players.base#canPlay
 37  * @return {boolean} If this player can play this media type.
 38  */
 39 minplayer.players.flash.canPlay = function(file) {
 40   return false;
 41 };
 42 
 43 /**
 44  * API to return the Flash player code provided params.
 45  *
 46  * @param {object} params The params used to populate the Flash code.
 47  * @return {object} A Flash DOM element.
 48  */
 49 minplayer.players.flash.getFlash = function(params) {
 50   // Get the protocol.
 51   var protocol = window.location.protocol;
 52   if (protocol.charAt(protocol.length - 1) == ':') {
 53     protocol = protocol.substring(0, protocol.length - 1);
 54   }
 55 
 56   // Convert the flashvars object to a string...
 57   var flashVars = jQuery.param(params.flashvars);
 58 
 59   // Set the codebase.
 60   var codebase = protocol + '://fpdownload.macromedia.com';
 61   codebase += '/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0';
 62 
 63   // Get the HTML flash object string.
 64   var flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
 65   flash += 'codebase="' + codebase + '" ';
 66   flash += 'playerType="flash" ';
 67   flash += 'width="' + params.width + '" ';
 68   flash += 'height="' + params.height + '" ';
 69   flash += 'id="' + params.id + '" ';
 70   flash += 'name="' + params.id + '"> ';
 71   flash += '<param name="allowScriptAccess" value="always"></param>';
 72   flash += '<param name="allowfullscreen" value="true" />';
 73   flash += '<param name="movie" value="' + params.swf + '"></param>';
 74   flash += '<param name="wmode" value="' + params.wmode + '"></param>';
 75   flash += '<param name="quality" value="high"></param>';
 76   flash += '<param name="FlashVars" value="' + flashVars + '"></param>';
 77   flash += '<embed src="' + params.swf + '" ';
 78   flash += 'quality="high" ';
 79   flash += 'width="' + params.width + '" height="' + params.height + '" ';
 80   flash += 'id="' + params.id + '" name="' + params.id + '" ';
 81   flash += 'swLiveConnect="true" allowScriptAccess="always" ';
 82   flash += 'wmode="' + params.wmode + '"';
 83   flash += 'allowfullscreen="true" type="application/x-shockwave-flash" ';
 84   flash += 'FlashVars="' + flashVars + '" ';
 85   flash += 'pluginspage="' + protocol;
 86   flash += '://www.macromedia.com/go/getflashplayer" />';
 87   flash += '</object>';
 88   return flash;
 89 };
 90 
 91 /**
 92  * @see minplayer.players.base#playerFound
 93  * @return {boolean} TRUE - if the player is in the DOM, FALSE otherwise.
 94  */
 95 minplayer.players.flash.prototype.playerFound = function() {
 96   return (this.display.find('object[playerType="flash"]').length > 0);
 97 };
 98 
 99 /**
100  * @see minplayer.players.base#getPlayer
101  * @return {object} The media player object.
102  */
103 minplayer.players.flash.prototype.getPlayer = function() {
104   // IE needs the object, everyone else just needs embed.
105   var object = jQuery.browser.msie ? 'object' : 'embed';
106   return jQuery(object, this.display).eq(0)[0];
107 };
108