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