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.plugin.construct 30 * @this minplayer.players.flash 31 */ 32 minplayer.players.flash.prototype.construct = function() { 33 34 // Call the players.base constructor. 35 minplayer.players.base.prototype.construct.call(this); 36 37 // Set the plugin name within the options. 38 this.options.pluginName = 'flash'; 39 }; 40 41 /** 42 * @see minplayer.players.base#getPriority 43 * 44 * @param {object} file A {@link minplayer.file} object. 45 * @return {number} The priority of this media player. 46 */ 47 minplayer.players.flash.getPriority = function(file) { 48 return 0; 49 }; 50 51 /** 52 * @see minplayer.players.base#canPlay 53 * 54 * @param {object} file A {@link minplayer.file} object. 55 * @return {boolean} If this player can play this media type. 56 */ 57 minplayer.players.flash.canPlay = function(file) { 58 return false; 59 }; 60 61 /** 62 * API to return the Flash player code provided params. 63 * 64 * @param {object} params The params used to populate the Flash code. 65 * @return {object} A Flash DOM element. 66 */ 67 minplayer.players.flash.prototype.getFlash = function(params) { 68 // Insert the swfobject javascript. 69 var tag = document.createElement('script'); 70 tag.src = '//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js'; 71 var firstScriptTag = document.getElementsByTagName('script')[0]; 72 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 73 74 // Create the swfobject. 75 setTimeout((function(player) { 76 return function tryAgain() { 77 if (typeof swfobject !== 'undefined') { 78 swfobject.embedSWF( 79 params.swf, 80 params.id, 81 params.width, 82 params.height, 83 '9.0.0', 84 false, 85 params.flashvars, 86 { 87 allowscriptaccess: 'always', 88 allowfullscreen: 'true', 89 wmode: params.wmode, 90 quality: 'high' 91 }, 92 { 93 id: params.id, 94 name: params.id, 95 playerType: 'flash' 96 }, 97 function(e) { 98 player.player = e.ref; 99 } 100 ); 101 } 102 else { 103 104 // Try again after 200 ms. 105 setTimeout(tryAgain, 200); 106 } 107 }; 108 })(this), 200); 109 110 // Return the div tag... 111 return '<div id="' + params.id + '"></div>'; 112 }; 113 114 /** 115 * @see minplayer.players.base#playerFound 116 * @return {boolean} TRUE - if the player is in the DOM, FALSE otherwise. 117 */ 118 minplayer.players.flash.prototype.playerFound = function() { 119 return (this.display.find('object[playerType="flash"]').length > 0); 120 }; 121