You are here

src_minplayer.plugin.js.html in HTML5 Media 7

  1 /** The minplayer namespace. */
  2 minplayer = minplayer || {};
  3 
  4 /** Static array to keep track of all plugins. */
  5 minplayer.plugins = minplayer.plugins || {};
  6 
  7 /** Static array to keep track of queues. */
  8 minplayer.queue = minplayer.queue || [];
  9 
 10 /** Mutex lock to keep multiple triggers from occuring. */
 11 minplayer.lock = false;
 12 
 13 /**
 14  * @constructor
 15  * @class The base class for all plugins.
 16  *
 17  * @param {string} name The name of this plugin.
 18  * @param {object} context The jQuery context.
 19  * @param {object} options This components options.
 20  * @param {object} queue The event queue to pass events around.
 21  */
 22 minplayer.plugin = function(name, context, options, queue) {
 23 
 24   /** The name of this plugin. */
 25   this.name = name;
 26 
 27   /** The ready flag. */
 28   this.pluginReady = false;
 29 
 30   /** The options for this plugin. */
 31   this.options = options || {};
 32 
 33   /** The event queue. */
 34   this.queue = queue || {};
 35 
 36   /** Keep track of already triggered events. */
 37   this.triggered = {};
 38 
 39   /** Create a queue lock. */
 40   this.lock = false;
 41 
 42   // Only call the constructor if we have a context.
 43   if (context) {
 44 
 45     /** Say that we are active. */
 46     this.active = true;
 47 
 48     /** Keep track of the context. */
 49     this.context = jQuery(context);
 50 
 51     // Construct this plugin.
 52     this.construct();
 53   }
 54 };
 55 
 56 /**
 57  * The constructor which is called once the context is set.
 58  * Any class deriving from the plugin class should place all context
 59  * dependant functionality within this function instead of the standard
 60  * constructor function since it is called on object derivation as well
 61  * as object creation.
 62  */
 63 minplayer.plugin.prototype.construct = function() {
 64 
 65   // Adds this as a plugin.
 66   this.addPlugin();
 67 };
 68 
 69 /**
 70  * Destructor.
 71  */
 72 minplayer.plugin.prototype.destroy = function() {
 73 
 74   // Unbind all events.
 75   this.active = false;
 76   this.unbind();
 77 };
 78 
 79 /**
 80  * Creates a new plugin within this context.
 81  *
 82  * @param {string} name The name of the plugin you wish to create.
 83  * @param {object} base The base object for this plugin.
 84  * @param {object} context The context which you would like to create.
 85  * @return {object} The new plugin object.
 86  */
 87 minplayer.plugin.prototype.create = function(name, base, context) {
 88   var plugin = null;
 89 
 90   // Make sure we have a base object.
 91   base = base || 'minplayer';
 92   if (!window[base][name]) {
 93     base = 'minplayer';
 94   }
 95 
 96   // Make sure there is a context.
 97   context = context || this.display;
 98 
 99   // See if this plugin exists within this object.
100   if (window[base][name]) {
101 
102     // Set the plugin.
103     plugin = window[base][name];
104 
105     // See if a template version of the plugin exists.
106     if (plugin[this.options.template]) {
107 
108       plugin = plugin[this.options.template];
109     }
110 
111     // Make sure the plugin is a function.
112     if (typeof plugin !== 'function') {
113       plugin = window['minplayer'][name];
114     }
115 
116     // Make sure it is a function.
117     if (typeof plugin === 'function') {
118       return new plugin(context, this.options);
119     }
120   }
121 
122   return null;
123 };
124 
125 /**
126  * Plugins should call this method when they are ready.
127  */
128 minplayer.plugin.prototype.ready = function() {
129 
130   // Keep this plugin from triggering multiple ready events.
131   if (!this.pluginReady) {
132 
133     // Set the ready flag.
134     this.pluginReady = true;
135 
136     // Now trigger that I am ready.
137     this.trigger('ready');
138 
139     // Check the queue.
140     this.checkQueue();
141   }
142 };
143 
144 /**
145  * Returns if this component is valid.
146  *
147  * @return {boolean} TRUE if the plugin display is valid.
148  */
149 minplayer.plugin.prototype.isValid = function() {
150   return !!this.options.id && this.active;
151 };
152 
153 /**
154  * Adds a new plugin to this player.
155  *
156  * @param {string} name The name of this plugin.
157  * @param {object} plugin A new plugin object, derived from media.plugin.
158  */
159 minplayer.plugin.prototype.addPlugin = function(name, plugin) {
160   name = name || this.name;
161   plugin = plugin || this;
162 
163   // Make sure the plugin is valid.
164   if (plugin.isValid()) {
165 
166     // If the plugins for this instance do not exist.
167     if (!minplayer.plugins[this.options.id]) {
168 
169       // Initialize the plugins.
170       minplayer.plugins[this.options.id] = {};
171     }
172 
173     if (!minplayer.plugins[this.options.id][name]) {
174 
175       // Add the plugins array.
176       minplayer.plugins[this.options.id][name] = [];
177     }
178 
179     // Add this plugin.
180     minplayer.plugins[this.options.id][name].push(plugin);
181 
182     // Now check the queue for this plugin.
183     this.checkQueue(plugin);
184   }
185 };
186 
187 /**
188  * Create a polling timer.
189  *
190  * @param {function} callback The function to call when you poll.
191  * @param {integer} interval The interval you would like to poll.
192  */
193 minplayer.plugin.prototype.poll = function(callback, interval) {
194   setTimeout((function(context) {
195     return function callLater() {
196       if (callback.call(context)) {
197         setTimeout(callLater, interval);
198       }
199     };
200   })(this), interval);
201 };
202 
203 /**
204  * Gets a plugin by name and calls callback when it is ready.
205  *
206  * @param {string} plugin The plugin of the plugin.
207  * @param {function} callback Called when the plugin is ready.
208  * @return {object} The plugin if no callback is provided.
209  */
210 minplayer.plugin.prototype.get = function(plugin, callback) {
211 
212   // If they pass just a callback, then return all plugins when ready.
213   if (typeof plugin === 'function') {
214     callback = plugin;
215     plugin = null;
216   }
217 
218   // Return the minplayer.get equivalent.
219   return minplayer.get.call(this, this.options.id, plugin, callback);
220 };
221 
222 /**
223  * Check the queue and execute it.
224  *
225  * @param {object} plugin The plugin object to check the queue against.
226  */
227 minplayer.plugin.prototype.checkQueue = function(plugin) {
228 
229   // Initialize our variables.
230   var q = null, i = 0, check = false, newqueue = [];
231 
232   // Normalize the plugin variable.
233   plugin = plugin || this;
234 
235   // Set the lock.
236   minplayer.lock = true;
237 
238   // Iterate through all the queues.
239   var length = minplayer.queue.length;
240   for (i = 0; i < length; i++) {
241     if (minplayer.queue.hasOwnProperty(i)) {
242       // Get the queue.
243       q = minplayer.queue[i];
244 
245       // Now check to see if this queue is about us.
246       check = !q.id && !q.plugin;
247       check |= (q.plugin == plugin.name);
248       check &= (!q.id || (q.id == this.options.id));
249 
250       // If the check passes...
251       if (check) {
252         check = minplayer.bind.call(
253           q.context,
254           q.event,
255           this.options.id,
256           plugin.name,
257           q.callback,
258           true
259         );
260       }
261 
262       // Add the queue back if it doesn't check out.
263       if (!check) {
264 
265         // Add this back to the queue.
266         newqueue.push(q);
267       }
268     }
269   }
270 
271   // Set the old queue to the new queue.
272   minplayer.queue = newqueue;
273 
274   // Release the lock.
275   minplayer.lock = false;
276 };
277 
278 /**
279  * Trigger a media event.
280  *
281  * @param {string} type The event type.
282  * @param {object} data The event data object.
283  * @return {object} The plugin object.
284  */
285 minplayer.plugin.prototype.trigger = function(type, data) {
286 
287   // Don't trigger if this plugin is inactive.
288   if (!this.active) {
289     return this;
290   }
291 
292   // Add this to our triggered array.
293   this.triggered[type] = data;
294 
295   // Check to make sure the queue for this type exists.
296   if (this.queue.hasOwnProperty(type)) {
297 
298     var i = 0, queue = {}, queuetype = this.queue[type];
299 
300     // Iterate through all the callbacks in this queue.
301     for (i in queuetype) {
302 
303       // Check to make sure the queue index exists.
304       if (queuetype.hasOwnProperty(i)) {
305 
306         // Setup the event object, and call the callback.
307         queue = queuetype[i];
308         queue.callback({target: this, data: queue.data}, data);
309       }
310     }
311   }
312 
313   // Return the plugin object.
314   return this;
315 };
316 
317 /**
318  * Bind to a media event.
319  *
320  * @param {string} type The event type.
321  * @param {object} data The data to bind with the event.
322  * @param {function} fn The callback function.
323  * @return {object} The plugin object.
324  **/
325 minplayer.plugin.prototype.bind = function(type, data, fn) {
326 
327   // Only bind if active.
328   if (!this.active) {
329     return this;
330   }
331 
332   // Allow the data to be the callback.
333   if (typeof data === 'function') {
334     fn = data;
335     data = null;
336   }
337 
338   // You must bind to a specific event and have a callback.
339   if (!type || !fn) {
340     return;
341   }
342 
343   // Initialize the queue for this type.
344   this.queue[type] = this.queue[type] || [];
345 
346   // Unbind any existing equivalent events.
347   this.unbind(type, fn);
348 
349   // Now add this event to the queue.
350   this.queue[type].push({
351     callback: fn,
352     data: data
353   });
354 
355   // Now see if this event has already been triggered.
356   if (this.triggered.hasOwnProperty(type)) {
357 
358     // Go ahead and trigger the event.
359     fn({target: this, data: data}, this.triggered[type]);
360   }
361 
362   // Return the plugin.
363   return this;
364 };
365 
366 /**
367  * Unbind a media event.
368  *
369  * @param {string} type The event type.
370  * @param {function} fn The callback function.
371  * @return {object} The plugin object.
372  **/
373 minplayer.plugin.prototype.unbind = function(type, fn) {
374 
375   // If this is locked then try again after 10ms.
376   if (this.lock) {
377     setTimeout((function(plugin) {
378       return function() {
379         plugin.unbind(type, fn);
380       };
381     })(this), 10);
382   }
383 
384   // Set the lock.
385   this.lock = true;
386 
387   // Get the queue type.
388   var queuetype = this.queue.hasOwnProperty(type) ? this.queue[type] : null;
389 
390   if (!type) {
391     this.queue = {};
392   }
393   else if (!fn) {
394     this.queue[type] = [];
395   }
396   else if (queuetype) {
397     // Iterate through all the callbacks and search for equal callbacks.
398     var i = 0, queue = {};
399     for (i in queuetype) {
400       if (queuetype.hasOwnProperty(i)) {
401         if (queuetype[i].callback === fn) {
402           queue = this.queue[type].splice(i, 1);
403           delete queue;
404         }
405       }
406     }
407   }
408 
409   // Reset the lock.
410   this.lock = false;
411 
412   // Return the plugin.
413   return this;
414 };
415 
416 /**
417  * Adds an item to the queue.
418  *
419  * @param {object} context The context which this is called within.
420  * @param {string} event The event to trigger on.
421  * @param {string} id The player ID.
422  * @param {string} plugin The name of the plugin.
423  * @param {function} callback Called when the event occurs.
424  */
425 minplayer.addQueue = function(context, event, id, plugin, callback) {
426 
427   // See if it is locked...
428   if (!minplayer.lock) {
429     minplayer.queue.push({
430       context: context,
431       id: id,
432       event: event,
433       plugin: plugin,
434       callback: callback
435     });
436   }
437   else {
438 
439     // If so, then try again after 10 milliseconds.
440     setTimeout(function() {
441       minplayer.addQueue(context, id, event, plugin, callback);
442     }, 10);
443   }
444 };
445 
446 /**
447  * Binds an event to a plugin instance, and if it doesn't exist, then caches
448  * it for a later time.
449  *
450  * @param {string} event The event to trigger on.
451  * @param {string} id The player ID.
452  * @param {string} plugin The name of the plugin.
453  * @param {function} callback Called when the event occurs.
454  * @param {boolean} fromCheck If this is from a checkqueue.
455  * @return {boolean} If the bind was successful.
456  * @this The object in context who called this method.
457  */
458 minplayer.bind = function(event, id, plugin, callback, fromCheck) {
459 
460   // If no callback exists, then just return false.
461   if (!callback) {
462     return false;
463   }
464 
465   // Get the plugins.
466   var plugins = minplayer.plugins;
467 
468   // Determine the selected plugins.
469   var selected = [];
470 
471   // Create a quick add.
472   var addSelected = function(id, plugin) {
473     if (plugins.hasOwnProperty(id) && plugins[id].hasOwnProperty(plugin)) {
474       var i = plugins[id][plugin].length;
475       while (i--) {
476         selected.push(plugins[id][plugin][i]);
477       }
478     }
479   };
480 
481   // If they provide id && plugin
482   if (id && plugin) {
483     addSelected(id, plugin);
484   }
485 
486   // If they provide no id but a plugin.
487   else if (!id && plugin) {
488     for (var id in plugins) {
489       addSelected(id, plugin);
490     }
491   }
492 
493   // If they provide an id but no plugin.
494   else if (id && !plugin && plugins[id]) {
495     for (var plugin in plugins[id]) {
496       addSelected(id, plugin);
497     }
498   }
499 
500   // If they provide niether an id or a plugin.
501   else if (!id && !plugin) {
502     for (var id in plugins) {
503       for (var plugin in plugins[id]) {
504         addSelected(id, plugin);
505       }
506     }
507   }
508 
509   // Iterate through the selected plugins and bind.
510   var i = selected.length;
511   while (i--) {
512     selected[i].bind(event, (function(context) {
513       return function(event) {
514         callback.call(context, event.target);
515       };
516     })(this));
517   }
518 
519   // Add it to the queue for post bindings...
520   if ((selected.length == 0) && !fromCheck) {
521     minplayer.addQueue(this, event, id, plugin, callback);
522   }
523 
524   // Return that this wasn't handled.
525   return (selected.length > 0);
526 };
527 
528 /**
529  * The main API for minPlayer.
530  *
531  * Provided that this function takes three parameters, there are 8 different
532  * ways to use this api.
533  *
534  *   id (0x100) - You want a specific player.
535  *   plugin (0x010) - You want a specific plugin.
536  *   callback (0x001) - You only want it when it is ready.
537  *
538  *   000 - You want all plugins from all players, ready or not.
539  *
540  *          var plugins = minplayer.get();
541  *
542  *   001 - You want all plugins from all players, but only when ready.
543  *
544  *          minplayer.get(function(plugin) {
545  *            // Code goes here.
546  *          });
547  *
548  *   010 - You want a specific plugin from all players, ready or not...
549  *
550  *          var medias = minplayer.get(null, 'media');
551  *
552  *   011 - You want a specific plugin from all players, but only when ready.
553  *
554  *          minplayer.get('player', function(player) {
555  *            // Code goes here.
556  *          });
557  *
558  *   100 - You want all plugins from a specific player, ready or not.
559  *
560  *          var plugins = minplayer.get('player_id');
561  *
562  *   101 - You want all plugins from a specific player, but only when ready.
563  *
564  *          minplayer.get('player_id', null, function(plugin) {
565  *            // Code goes here.
566  *          });
567  *
568  *   110 - You want a specific plugin from a specific player, ready or not.
569  *
570  *          var plugin = minplayer.get('player_id', 'media');
571  *
572  *   111 - You want a specific plugin from a specific player, only when ready.
573  *
574  *          minplayer.get('player_id', 'media', function(media) {
575  *            // Code goes here.
576  *          });
577  *
578  * @this The context in which this function was called.
579  * @param {string} id The ID of the widget to get the plugins from.
580  * @param {string} plugin The name of the plugin.
581  * @param {function} callback Called when the plugin is ready.
582  * @return {object} The plugin object if it is immediately available.
583  */
584 minplayer.get = function(id, plugin, callback) {
585 
586   // Normalize the arguments for a better interface.
587   if (typeof id === 'function') {
588     callback = id;
589     plugin = id = null;
590   }
591 
592   if (typeof plugin === 'function') {
593     callback = plugin;
594     plugin = id;
595     id = null;
596   }
597 
598   // Make sure the callback is a callback.
599   callback = (typeof callback === 'function') ? callback : null;
600 
601   // If a callback was provided, then just go ahead and bind.
602   if (callback) {
603     minplayer.bind.call(this, 'ready', id, plugin, callback);
604     return;
605   }
606 
607   // Get the plugins.
608   var plugins = minplayer.plugins;
609 
610   // 0x000
611   if (!id && !plugin && !callback) {
612     return plugins;
613   }
614   // 0x100
615   else if (id && !plugin && !callback) {
616     return plugins[id];
617   }
618   // 0x110
619   else if (id && plugin && !callback) {
620     return plugins[id][plugin];
621   }
622   // 0x010
623   else if (!id && plugin && !callback) {
624     var plugin_types = [];
625     for (var id in plugins) {
626       if (plugins.hasOwnProperty(id) && plugins[id].hasOwnProperty(plugin)) {
627         var i = plugins[id][plugin].length;
628         while (i--) {
629           plugin_types.push(plugins[id][plugin][i]);
630         }
631       }
632     }
633     return plugin_types;
634   }
635 };
636 

File

player/doc/symbols/src/src_minplayer.plugin.js.html
View source
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/** The minplayer namespace. */</span><span class="WHIT">
<span class='line'>  2</span> </span><span class="NAME">minplayer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">minplayer</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  3</span> 
<span class='line'>  4</span> </span><span class="COMM">/** Static array to keep track of all plugins. */</span><span class="WHIT">
<span class='line'>  5</span> </span><span class="NAME">minplayer.plugins</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">minplayer.plugins</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  6</span> 
<span class='line'>  7</span> </span><span class="COMM">/** Static array to keep track of queues. */</span><span class="WHIT">
<span class='line'>  8</span> </span><span class="NAME">minplayer.queue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">minplayer.queue</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  9</span> 
<span class='line'> 10</span> </span><span class="COMM">/** Mutex lock to keep multiple triggers from occuring. */</span><span class="WHIT">
<span class='line'> 11</span> </span><span class="NAME">minplayer.lock</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 12</span> 
<span class='line'> 13</span> </span><span class="COMM">/**
<span class='line'> 14</span>  * @constructor
<span class='line'> 15</span>  * @class The base class for all plugins.
<span class='line'> 16</span>  *
<span class='line'> 17</span>  * @param {string} name The name of this plugin.
<span class='line'> 18</span>  * @param {object} context The jQuery context.
<span class='line'> 19</span>  * @param {object} options This components options.
<span class='line'> 20</span>  * @param {object} queue The event queue to pass events around.
<span class='line'> 21</span>  */</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="NAME">minplayer.plugin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">context</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">queue</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 23</span> 
<span class='line'> 24</span> </span><span class="WHIT">  </span><span class="COMM">/** The name of this plugin. */</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="WHIT">  </span><span class="NAME">this.name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">name</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 26</span> 
<span class='line'> 27</span> </span><span class="WHIT">  </span><span class="COMM">/** The ready flag. */</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="WHIT">  </span><span class="NAME">this.pluginReady</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 29</span> 
<span class='line'> 30</span> </span><span class="WHIT">  </span><span class="COMM">/** The options for this plugin. */</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">  </span><span class="NAME">this.options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 32</span> 
<span class='line'> 33</span> </span><span class="WHIT">  </span><span class="COMM">/** The event queue. */</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT">  </span><span class="NAME">this.queue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">queue</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 35</span> 
<span class='line'> 36</span> </span><span class="WHIT">  </span><span class="COMM">/** Keep track of already triggered events. */</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">  </span><span class="NAME">this.triggered</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 38</span> 
<span class='line'> 39</span> </span><span class="WHIT">  </span><span class="COMM">/** Create a queue lock. */</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT">  </span><span class="NAME">this.lock</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> 
<span class='line'> 42</span> </span><span class="WHIT">  </span><span class="COMM">// Only call the constructor if we have a context.</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 44</span> 
<span class='line'> 45</span> </span><span class="WHIT">    </span><span class="COMM">/** Say that we are active. */</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">    </span><span class="NAME">this.active</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 47</span> 
<span class='line'> 48</span> </span><span class="WHIT">    </span><span class="COMM">/** Keep track of the context. */</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">    </span><span class="NAME">this.context</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jQuery</span><span class="PUNC">(</span><span class="NAME">context</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 50</span> 
<span class='line'> 51</span> </span><span class="WHIT">    </span><span class="COMM">// Construct this plugin.</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">    </span><span class="NAME">this.construct</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 55</span> 
<span class='line'> 56</span> </span><span class="COMM">/**
<span class='line'> 57</span>  * The constructor which is called once the context is set.
<span class='line'> 58</span>  * Any class deriving from the plugin class should place all context
<span class='line'> 59</span>  * dependant functionality within this function instead of the standard
<span class='line'> 60</span>  * constructor function since it is called on object derivation as well
<span class='line'> 61</span>  * as object creation.
<span class='line'> 62</span>  */</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="NAME">minplayer.plugin.prototype.construct</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 64</span> 
<span class='line'> 65</span> </span><span class="WHIT">  </span><span class="COMM">// Adds this as a plugin.</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">  </span><span class="NAME">this.addPlugin</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> 
<span class='line'> 69</span> </span><span class="COMM">/**
<span class='line'> 70</span>  * Destructor.
<span class='line'> 71</span>  */</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="NAME">minplayer.plugin.prototype.destroy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 73</span> 
<span class='line'> 74</span> </span><span class="WHIT">  </span><span class="COMM">// Unbind all events.</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">  </span><span class="NAME">this.active</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">  </span><span class="NAME">this.unbind</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> 
<span class='line'> 79</span> </span><span class="COMM">/**
<span class='line'> 80</span>  * Creates a new plugin within this context.
<span class='line'> 81</span>  *
<span class='line'> 82</span>  * @param {string} name The name of the plugin you wish to create.
<span class='line'> 83</span>  * @param {object} base The base object for this plugin.
<span class='line'> 84</span>  * @param {object} context The context which you would like to create.
<span class='line'> 85</span>  * @return {object} The new plugin object.
<span class='line'> 86</span>  */</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="NAME">minplayer.plugin.prototype.create</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">base</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> 
<span class='line'> 90</span> </span><span class="WHIT">  </span><span class="COMM">// Make sure we have a base object.</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">  </span><span class="NAME">base</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">base</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">'minplayer'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">window</span><span class="PUNC">[</span><span class="NAME">base</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">    </span><span class="NAME">base</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'minplayer'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 95</span> 
<span class='line'> 96</span> </span><span class="WHIT">  </span><span class="COMM">// Make sure there is a context.</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">  </span><span class="NAME">context</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">context</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">this.display</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span> 
<span class='line'> 99</span> </span><span class="WHIT">  </span><span class="COMM">// See if this plugin exists within this object.</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">window</span><span class="PUNC">[</span><span class="NAME">base</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>101</span> 
<span class='line'>102</span> </span><span class="WHIT">    </span><span class="COMM">// Set the plugin.</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">    </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">[</span><span class="NAME">base</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> 
<span class='line'>105</span> </span><span class="WHIT">    </span><span class="COMM">// See if a template version of the plugin exists.</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">plugin</span><span class="PUNC">[</span><span class="NAME">this.options.template</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>107</span> 
<span class='line'>108</span> </span><span class="WHIT">      </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">[</span><span class="NAME">this.options.template</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>110</span> 
<span class='line'>111</span> </span><span class="WHIT">    </span><span class="COMM">// Make sure the plugin is a function.</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">      </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">'minplayer'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>115</span> 
<span class='line'>116</span> </span><span class="WHIT">    </span><span class="COMM">// Make sure it is a function.</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">(</span><span class="NAME">context</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>121</span> 
<span class='line'>122</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>124</span> 
<span class='line'>125</span> </span><span class="COMM">/**
<span class='line'>126</span>  * Plugins should call this method when they are ready.
<span class='line'>127</span>  */</span><span class="WHIT">
<span class='line'>128</span> </span><span class="NAME">minplayer.plugin.prototype.ready</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>129</span> 
<span class='line'>130</span> </span><span class="WHIT">  </span><span class="COMM">// Keep this plugin from triggering multiple ready events.</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.pluginReady</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>132</span> 
<span class='line'>133</span> </span><span class="WHIT">    </span><span class="COMM">// Set the ready flag.</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">    </span><span class="NAME">this.pluginReady</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> 
<span class='line'>136</span> </span><span class="WHIT">    </span><span class="COMM">// Now trigger that I am ready.</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">    </span><span class="NAME">this.trigger</span><span class="PUNC">(</span><span class="STRN">'ready'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>138</span> 
<span class='line'>139</span> </span><span class="WHIT">    </span><span class="COMM">// Check the queue.</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">    </span><span class="NAME">this.checkQueue</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>142</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>143</span> 
<span class='line'>144</span> </span><span class="COMM">/**
<span class='line'>145</span>  * Returns if this component is valid.
<span class='line'>146</span>  *
<span class='line'>147</span>  * @return {boolean} TRUE if the plugin display is valid.
<span class='line'>148</span>  */</span><span class="WHIT">
<span class='line'>149</span> </span><span class="NAME">minplayer.plugin.prototype.isValid</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">!</span><span class="NAME">this.options.id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.active</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>151</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>152</span> 
<span class='line'>153</span> </span><span class="COMM">/**
<span class='line'>154</span>  * Adds a new plugin to this player.
<span class='line'>155</span>  *
<span class='line'>156</span>  * @param {string} name The name of this plugin.
<span class='line'>157</span>  * @param {object} plugin A new plugin object, derived from media.plugin.
<span class='line'>158</span>  */</span><span class="WHIT">
<span class='line'>159</span> </span><span class="NAME">minplayer.plugin.prototype.addPlugin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">  </span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">name</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">this.name</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">  </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>162</span> 
<span class='line'>163</span> </span><span class="WHIT">  </span><span class="COMM">// Make sure the plugin is valid.</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">plugin.isValid</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>165</span> 
<span class='line'>166</span> </span><span class="WHIT">    </span><span class="COMM">// If the plugins for this instance do not exist.</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">minplayer.plugins</span><span class="PUNC">[</span><span class="NAME">this.options.id</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>168</span> 
<span class='line'>169</span> </span><span class="WHIT">      </span><span class="COMM">// Initialize the plugins.</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">      </span><span class="NAME">minplayer.plugins</span><span class="PUNC">[</span><span class="NAME">this.options.id</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>172</span> 
<span class='line'>173</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">minplayer.plugins</span><span class="PUNC">[</span><span class="NAME">this.options.id</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>174</span> 
<span class='line'>175</span> </span><span class="WHIT">      </span><span class="COMM">// Add the plugins array.</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">      </span><span class="NAME">minplayer.plugins</span><span class="PUNC">[</span><span class="NAME">this.options.id</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>177</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>178</span> 
<span class='line'>179</span> </span><span class="WHIT">    </span><span class="COMM">// Add this plugin.</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">    </span><span class="NAME">minplayer.plugins</span><span class="PUNC">[</span><span class="NAME">this.options.id</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>181</span> 
<span class='line'>182</span> </span><span class="WHIT">    </span><span class="COMM">// Now check the queue for this plugin.</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">    </span><span class="NAME">this.checkQueue</span><span class="PUNC">(</span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>185</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> 
<span class='line'>187</span> </span><span class="COMM">/**
<span class='line'>188</span>  * Create a polling timer.
<span class='line'>189</span>  *
<span class='line'>190</span>  * @param {function} callback The function to call when you poll.
<span class='line'>191</span>  * @param {integer} interval The interval you would like to poll.
<span class='line'>192</span>  */</span><span class="WHIT">
<span class='line'>193</span> </span><span class="NAME">minplayer.plugin.prototype.poll</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">interval</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">  </span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">callLater</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">context</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">        </span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="NAME">callLater</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">interval</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">interval</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>201</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>202</span> 
<span class='line'>203</span> </span><span class="COMM">/**
<span class='line'>204</span>  * Gets a plugin by name and calls callback when it is ready.
<span class='line'>205</span>  *
<span class='line'>206</span>  * @param {string} plugin The plugin of the plugin.
<span class='line'>207</span>  * @param {function} callback Called when the plugin is ready.
<span class='line'>208</span>  * @return {object} The plugin if no callback is provided.
<span class='line'>209</span>  */</span><span class="WHIT">
<span class='line'>210</span> </span><span class="NAME">minplayer.plugin.prototype.get</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">plugin</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>211</span> 
<span class='line'>212</span> </span><span class="WHIT">  </span><span class="COMM">// If they pass just a callback, then return all plugins when ready.</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">    </span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">    </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>217</span> 
<span class='line'>218</span> </span><span class="WHIT">  </span><span class="COMM">// Return the minplayer.get equivalent.</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">minplayer.get.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.options.id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>221</span> 
<span class='line'>222</span> </span><span class="COMM">/**
<span class='line'>223</span>  * Check the queue and execute it.
<span class='line'>224</span>  *
<span class='line'>225</span>  * @param {object} plugin The plugin object to check the queue against.
<span class='line'>226</span>  */</span><span class="WHIT">
<span class='line'>227</span> </span><span class="NAME">minplayer.plugin.prototype.checkQueue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>228</span> 
<span class='line'>229</span> </span><span class="WHIT">  </span><span class="COMM">// Initialize our variables.</span><span class="WHIT">
<span class='line'>230</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">q</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">check</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">newqueue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>231</span> 
<span class='line'>232</span> </span><span class="WHIT">  </span><span class="COMM">// Normalize the plugin variable.</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT">  </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>234</span> 
<span class='line'>235</span> </span><span class="WHIT">  </span><span class="COMM">// Set the lock.</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">  </span><span class="NAME">minplayer.lock</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>237</span> 
<span class='line'>238</span> </span><span class="WHIT">  </span><span class="COMM">// Iterate through all the queues.</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">length</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">minplayer.queue.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">  </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">minplayer.queue.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">      </span><span class="COMM">// Get the queue.</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">      </span><span class="NAME">q</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">minplayer.queue</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>244</span> 
<span class='line'>245</span> </span><span class="WHIT">      </span><span class="COMM">// Now check to see if this queue is about us.</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT">      </span><span class="NAME">check</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">q.id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">q.plugin</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">      </span><span class="NAME">check</span><span class="WHIT"> </span><span class="PUNC">|</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">q.plugin</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">plugin.name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>248</span> </span><span class="WHIT">      </span><span class="NAME">check</span><span class="WHIT"> </span><span class="PUNC">&</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">q.id</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">q.id</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">this.options.id</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>249</span> 
<span class='line'>250</span> </span><span class="WHIT">      </span><span class="COMM">// If the check passes...</span><span class="WHIT">
<span class='line'>251</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">check</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">        </span><span class="NAME">check</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">minplayer.bind.call</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT">          </span><span class="NAME">q.context</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>254</span> </span><span class="WHIT">          </span><span class="NAME">q.event</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">          </span><span class="NAME">this.options.id</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">          </span><span class="NAME">plugin.name</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT">          </span><span class="NAME">q.callback</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT">          </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT">        </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>261</span> 
<span class='line'>262</span> </span><span class="WHIT">      </span><span class="COMM">// Add the queue back if it doesn't check out.</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">check</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>264</span> 
<span class='line'>265</span> </span><span class="WHIT">        </span><span class="COMM">// Add this back to the queue.</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">        </span><span class="NAME">newqueue.push</span><span class="PUNC">(</span><span class="NAME">q</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>270</span> 
<span class='line'>271</span> </span><span class="WHIT">  </span><span class="COMM">// Set the old queue to the new queue.</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">  </span><span class="NAME">minplayer.queue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newqueue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>273</span> 
<span class='line'>274</span> </span><span class="WHIT">  </span><span class="COMM">// Release the lock.</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">  </span><span class="NAME">minplayer.lock</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>276</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>277</span> 
<span class='line'>278</span> </span><span class="COMM">/**
<span class='line'>279</span>  * Trigger a media event.
<span class='line'>280</span>  *
<span class='line'>281</span>  * @param {string} type The event type.
<span class='line'>282</span>  * @param {object} data The event data object.
<span class='line'>283</span>  * @return {object} The plugin object.
<span class='line'>284</span>  */</span><span class="WHIT">
<span class='line'>285</span> </span><span class="NAME">minplayer.plugin.prototype.trigger</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>286</span> 
<span class='line'>287</span> </span><span class="WHIT">  </span><span class="COMM">// Don't trigger if this plugin is inactive.</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.active</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>291</span> 
<span class='line'>292</span> </span><span class="WHIT">  </span><span class="COMM">// Add this to our triggered array.</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">  </span><span class="NAME">this.triggered</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>294</span> 
<span class='line'>295</span> </span><span class="WHIT">  </span><span class="COMM">// Check to make sure the queue for this type exists.</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.queue.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>297</span> 
<span class='line'>298</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">queue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">queuetype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.queue</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>299</span> 
<span class='line'>300</span> </span><span class="WHIT">    </span><span class="COMM">// Iterate through all the callbacks in this queue.</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">queuetype</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>302</span> 
<span class='line'>303</span> </span><span class="WHIT">      </span><span class="COMM">// Check to make sure the queue index exists.</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">queuetype.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>305</span> 
<span class='line'>306</span> </span><span class="WHIT">        </span><span class="COMM">// Setup the event object, and call the callback.</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">        </span><span class="NAME">queue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">queuetype</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT">        </span><span class="NAME">queue.callback</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="NAME">target</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">queue.data</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>312</span> 
<span class='line'>313</span> </span><span class="WHIT">  </span><span class="COMM">// Return the plugin object.</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>315</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>316</span> 
<span class='line'>317</span> </span><span class="COMM">/**
<span class='line'>318</span>  * Bind to a media event.
<span class='line'>319</span>  *
<span class='line'>320</span>  * @param {string} type The event type.
<span class='line'>321</span>  * @param {object} data The data to bind with the event.
<span class='line'>322</span>  * @param {function} fn The callback function.
<span class='line'>323</span>  * @return {object} The plugin object.
<span class='line'>324</span>  **/</span><span class="WHIT">
<span class='line'>325</span> </span><span class="NAME">minplayer.plugin.prototype.bind</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>326</span> 
<span class='line'>327</span> </span><span class="WHIT">  </span><span class="COMM">// Only bind if active.</span><span class="WHIT">
<span class='line'>328</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.active</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>329</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>330</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>331</span> 
<span class='line'>332</span> </span><span class="WHIT">  </span><span class="COMM">// Allow the data to be the callback.</span><span class="WHIT">
<span class='line'>333</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT">    </span><span class="NAME">fn</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT">    </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>336</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>337</span> 
<span class='line'>338</span> </span><span class="WHIT">  </span><span class="COMM">// You must bind to a specific event and have a callback.</span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">fn</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>340</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>341</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>342</span> 
<span class='line'>343</span> </span><span class="WHIT">  </span><span class="COMM">// Initialize the queue for this type.</span><span class="WHIT">
<span class='line'>344</span> </span><span class="WHIT">  </span><span class="NAME">this.queue</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.queue</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>345</span> 
<span class='line'>346</span> </span><span class="WHIT">  </span><span class="COMM">// Unbind any existing equivalent events.</span><span class="WHIT">
<span class='line'>347</span> </span><span class="WHIT">  </span><span class="NAME">this.unbind</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>348</span> 
<span class='line'>349</span> </span><span class="WHIT">  </span><span class="COMM">// Now add this event to the queue.</span><span class="WHIT">
<span class='line'>350</span> </span><span class="WHIT">  </span><span class="NAME">this.queue</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>351</span> </span><span class="WHIT">    </span><span class="NAME">callback</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>352</span> </span><span class="WHIT">    </span><span class="NAME">data</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">data</span><span class="WHIT">
<span class='line'>353</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>354</span> 
<span class='line'>355</span> </span><span class="WHIT">  </span><span class="COMM">// Now see if this event has already been triggered.</span><span class="WHIT">
<span class='line'>356</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.triggered.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>357</span> 
<span class='line'>358</span> </span><span class="WHIT">    </span><span class="COMM">// Go ahead and trigger the event.</span><span class="WHIT">
<span class='line'>359</span> </span><span class="WHIT">    </span><span class="NAME">fn</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="NAME">target</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.triggered</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>360</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>361</span> 
<span class='line'>362</span> </span><span class="WHIT">  </span><span class="COMM">// Return the plugin.</span><span class="WHIT">
<span class='line'>363</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>364</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>365</span> 
<span class='line'>366</span> </span><span class="COMM">/**
<span class='line'>367</span>  * Unbind a media event.
<span class='line'>368</span>  *
<span class='line'>369</span>  * @param {string} type The event type.
<span class='line'>370</span>  * @param {function} fn The callback function.
<span class='line'>371</span>  * @return {object} The plugin object.
<span class='line'>372</span>  **/</span><span class="WHIT">
<span class='line'>373</span> </span><span class="NAME">minplayer.plugin.prototype.unbind</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>374</span> 
<span class='line'>375</span> </span><span class="WHIT">  </span><span class="COMM">// If this is locked then try again after 10ms.</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.lock</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>377</span> </span><span class="WHIT">    </span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>378</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>379</span> </span><span class="WHIT">        </span><span class="NAME">plugin.unbind</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>383</span> 
<span class='line'>384</span> </span><span class="WHIT">  </span><span class="COMM">// Set the lock.</span><span class="WHIT">
<span class='line'>385</span> </span><span class="WHIT">  </span><span class="NAME">this.lock</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>386</span> 
<span class='line'>387</span> </span><span class="WHIT">  </span><span class="COMM">// Get the queue type.</span><span class="WHIT">
<span class='line'>388</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">queuetype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.queue.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">this.queue</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>389</span> 
<span class='line'>390</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT">    </span><span class="NAME">this.queue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">  </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">fn</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT">    </span><span class="NAME">this.queue</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>396</span> </span><span class="WHIT">  </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">queuetype</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>397</span> </span><span class="WHIT">    </span><span class="COMM">// Iterate through all the callbacks and search for equal callbacks.</span><span class="WHIT">
<span class='line'>398</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">queue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>399</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">queuetype</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>400</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">queuetype.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>401</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">queuetype</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">fn</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>402</span> </span><span class="WHIT">          </span><span class="NAME">queue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.queue</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">splice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>403</span> </span><span class="WHIT">          </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">queue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>404</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>405</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>406</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>407</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>408</span> 
<span class='line'>409</span> </span><span class="WHIT">  </span><span class="COMM">// Reset the lock.</span><span class="WHIT">
<span class='line'>410</span> </span><span class="WHIT">  </span><span class="NAME">this.lock</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>411</span> 
<span class='line'>412</span> </span><span class="WHIT">  </span><span class="COMM">// Return the plugin.</span><span class="WHIT">
<span class='line'>413</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>414</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>415</span> 
<span class='line'>416</span> </span><span class="COMM">/**
<span class='line'>417</span>  * Adds an item to the queue.
<span class='line'>418</span>  *
<span class='line'>419</span>  * @param {object} context The context which this is called within.
<span class='line'>420</span>  * @param {string} event The event to trigger on.
<span class='line'>421</span>  * @param {string} id The player ID.
<span class='line'>422</span>  * @param {string} plugin The name of the plugin.
<span class='line'>423</span>  * @param {function} callback Called when the event occurs.
<span class='line'>424</span>  */</span><span class="WHIT">
<span class='line'>425</span> </span><span class="NAME">minplayer.addQueue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">context</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>426</span> 
<span class='line'>427</span> </span><span class="WHIT">  </span><span class="COMM">// See if it is locked...</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">minplayer.lock</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT">    </span><span class="NAME">minplayer.queue.push</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>430</span> </span><span class="WHIT">      </span><span class="NAME">context</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">context</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>431</span> </span><span class="WHIT">      </span><span class="NAME">id</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>432</span> </span><span class="WHIT">      </span><span class="NAME">event</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>433</span> </span><span class="WHIT">      </span><span class="NAME">plugin</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>434</span> </span><span class="WHIT">      </span><span class="NAME">callback</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="WHIT">
<span class='line'>435</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>436</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>437</span> </span><span class="WHIT">  </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>438</span> 
<span class='line'>439</span> </span><span class="WHIT">    </span><span class="COMM">// If so, then try again after 10 milliseconds.</span><span class="WHIT">
<span class='line'>440</span> </span><span class="WHIT">    </span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>441</span> </span><span class="WHIT">      </span><span class="NAME">minplayer.addQueue</span><span class="PUNC">(</span><span class="NAME">context</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>442</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>443</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>444</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>445</span> 
<span class='line'>446</span> </span><span class="COMM">/**
<span class='line'>447</span>  * Binds an event to a plugin instance, and if it doesn't exist, then caches
<span class='line'>448</span>  * it for a later time.
<span class='line'>449</span>  *
<span class='line'>450</span>  * @param {string} event The event to trigger on.
<span class='line'>451</span>  * @param {string} id The player ID.
<span class='line'>452</span>  * @param {string} plugin The name of the plugin.
<span class='line'>453</span>  * @param {function} callback Called when the event occurs.
<span class='line'>454</span>  * @param {boolean} fromCheck If this is from a checkqueue.
<span class='line'>455</span>  * @return {boolean} If the bind was successful.
<span class='line'>456</span>  * @this The object in context who called this method.
<span class='line'>457</span>  */</span><span class="WHIT">
<span class='line'>458</span> </span><span class="NAME">minplayer.bind</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fromCheck</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>459</span> 
<span class='line'>460</span> </span><span class="WHIT">  </span><span class="COMM">// If no callback exists, then just return false.</span><span class="WHIT">
<span class='line'>461</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>462</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>464</span> 
<span class='line'>465</span> </span><span class="WHIT">  </span><span class="COMM">// Get the plugins.</span><span class="WHIT">
<span class='line'>466</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">minplayer.plugins</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>467</span> 
<span class='line'>468</span> </span><span class="WHIT">  </span><span class="COMM">// Determine the selected plugins.</span><span class="WHIT">
<span class='line'>469</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">selected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>470</span> 
<span class='line'>471</span> </span><span class="WHIT">  </span><span class="COMM">// Create a quick add.</span><span class="WHIT">
<span class='line'>472</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">addSelected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>473</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">plugins.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>474</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">plugin</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>475</span> </span><span class="WHIT">      </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>476</span> </span><span class="WHIT">        </span><span class="NAME">selected.push</span><span class="PUNC">(</span><span class="NAME">plugins</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">plugin</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>477</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>478</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>479</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>480</span> 
<span class='line'>481</span> </span><span class="WHIT">  </span><span class="COMM">// If they provide id && plugin</span><span class="WHIT">
<span class='line'>482</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>483</span> </span><span class="WHIT">    </span><span class="NAME">addSelected</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>484</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>485</span> 
<span class='line'>486</span> </span><span class="WHIT">  </span><span class="COMM">// If they provide no id but a plugin.</span><span class="WHIT">
<span class='line'>487</span> </span><span class="WHIT">  </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>488</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>489</span> </span><span class="WHIT">      </span><span class="NAME">addSelected</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>490</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>491</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>492</span> 
<span class='line'>493</span> </span><span class="WHIT">  </span><span class="COMM">// If they provide an id but no plugin.</span><span class="WHIT">
<span class='line'>494</span> </span><span class="WHIT">  </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>495</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>496</span> </span><span class="WHIT">      </span><span class="NAME">addSelected</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>497</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>498</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>499</span> 
<span class='line'>500</span> </span><span class="WHIT">  </span><span class="COMM">// If they provide niether an id or a plugin.</span><span class="WHIT">
<span class='line'>501</span> </span><span class="WHIT">  </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>503</span> </span><span class="WHIT">      </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>504</span> </span><span class="WHIT">        </span><span class="NAME">addSelected</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>505</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>506</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>507</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>508</span> 
<span class='line'>509</span> </span><span class="WHIT">  </span><span class="COMM">// Iterate through the selected plugins and bind.</span><span class="WHIT">
<span class='line'>510</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">selected.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>511</span> </span><span class="WHIT">  </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>512</span> </span><span class="WHIT">    </span><span class="NAME">selected</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">bind</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">context</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>513</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>514</span> </span><span class="WHIT">        </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">context</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event.target</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>515</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>516</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>517</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>518</span> 
<span class='line'>519</span> </span><span class="WHIT">  </span><span class="COMM">// Add it to the queue for post bindings...</span><span class="WHIT">
<span class='line'>520</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">selected.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">fromCheck</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>521</span> </span><span class="WHIT">    </span><span class="NAME">minplayer.addQueue</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>522</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>523</span> 
<span class='line'>524</span> </span><span class="WHIT">  </span><span class="COMM">// Return that this wasn't handled.</span><span class="WHIT">
<span class='line'>525</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">selected.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>526</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>527</span> 
<span class='line'>528</span> </span><span class="COMM">/**
<span class='line'>529</span>  * The main API for minPlayer.
<span class='line'>530</span>  *
<span class='line'>531</span>  * Provided that this function takes three parameters, there are 8 different
<span class='line'>532</span>  * ways to use this api.
<span class='line'>533</span>  *
<span class='line'>534</span>  *   id (0x100) - You want a specific player.
<span class='line'>535</span>  *   plugin (0x010) - You want a specific plugin.
<span class='line'>536</span>  *   callback (0x001) - You only want it when it is ready.
<span class='line'>537</span>  *
<span class='line'>538</span>  *   000 - You want all plugins from all players, ready or not.
<span class='line'>539</span>  *
<span class='line'>540</span>  *          var plugins = minplayer.get();
<span class='line'>541</span>  *
<span class='line'>542</span>  *   001 - You want all plugins from all players, but only when ready.
<span class='line'>543</span>  *
<span class='line'>544</span>  *          minplayer.get(function(plugin) {
<span class='line'>545</span>  *            // Code goes here.
<span class='line'>546</span>  *          });
<span class='line'>547</span>  *
<span class='line'>548</span>  *   010 - You want a specific plugin from all players, ready or not...
<span class='line'>549</span>  *
<span class='line'>550</span>  *          var medias = minplayer.get(null, 'media');
<span class='line'>551</span>  *
<span class='line'>552</span>  *   011 - You want a specific plugin from all players, but only when ready.
<span class='line'>553</span>  *
<span class='line'>554</span>  *          minplayer.get('player', function(player) {
<span class='line'>555</span>  *            // Code goes here.
<span class='line'>556</span>  *          });
<span class='line'>557</span>  *
<span class='line'>558</span>  *   100 - You want all plugins from a specific player, ready or not.
<span class='line'>559</span>  *
<span class='line'>560</span>  *          var plugins = minplayer.get('player_id');
<span class='line'>561</span>  *
<span class='line'>562</span>  *   101 - You want all plugins from a specific player, but only when ready.
<span class='line'>563</span>  *
<span class='line'>564</span>  *          minplayer.get('player_id', null, function(plugin) {
<span class='line'>565</span>  *            // Code goes here.
<span class='line'>566</span>  *          });
<span class='line'>567</span>  *
<span class='line'>568</span>  *   110 - You want a specific plugin from a specific player, ready or not.
<span class='line'>569</span>  *
<span class='line'>570</span>  *          var plugin = minplayer.get('player_id', 'media');
<span class='line'>571</span>  *
<span class='line'>572</span>  *   111 - You want a specific plugin from a specific player, only when ready.
<span class='line'>573</span>  *
<span class='line'>574</span>  *          minplayer.get('player_id', 'media', function(media) {
<span class='line'>575</span>  *            // Code goes here.
<span class='line'>576</span>  *          });
<span class='line'>577</span>  *
<span class='line'>578</span>  * @this The context in which this function was called.
<span class='line'>579</span>  * @param {string} id The ID of the widget to get the plugins from.
<span class='line'>580</span>  * @param {string} plugin The name of the plugin.
<span class='line'>581</span>  * @param {function} callback Called when the plugin is ready.
<span class='line'>582</span>  * @return {object} The plugin object if it is immediately available.
<span class='line'>583</span>  */</span><span class="WHIT">
<span class='line'>584</span> </span><span class="NAME">minplayer.get</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>585</span> 
<span class='line'>586</span> </span><span class="WHIT">  </span><span class="COMM">// Normalize the arguments for a better interface.</span><span class="WHIT">
<span class='line'>587</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>588</span> </span><span class="WHIT">    </span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>589</span> </span><span class="WHIT">    </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>590</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>591</span> 
<span class='line'>592</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>593</span> </span><span class="WHIT">    </span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>594</span> </span><span class="WHIT">    </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>595</span> </span><span class="WHIT">    </span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>596</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>597</span> 
<span class='line'>598</span> </span><span class="WHIT">  </span><span class="COMM">// Make sure the callback is a callback.</span><span class="WHIT">
<span class='line'>599</span> </span><span class="WHIT">  </span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>600</span> 
<span class='line'>601</span> </span><span class="WHIT">  </span><span class="COMM">// If a callback was provided, then just go ahead and bind.</span><span class="WHIT">
<span class='line'>602</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>603</span> </span><span class="WHIT">    </span><span class="NAME">minplayer.bind.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'ready'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>604</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>605</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>606</span> 
<span class='line'>607</span> </span><span class="WHIT">  </span><span class="COMM">// Get the plugins.</span><span class="WHIT">
<span class='line'>608</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">minplayer.plugins</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>609</span> 
<span class='line'>610</span> </span><span class="WHIT">  </span><span class="COMM">// 0x000</span><span class="WHIT">
<span class='line'>611</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>612</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>613</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>614</span> </span><span class="WHIT">  </span><span class="COMM">// 0x100</span><span class="WHIT">
<span class='line'>615</span> </span><span class="WHIT">  </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>616</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>617</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>618</span> </span><span class="WHIT">  </span><span class="COMM">// 0x110</span><span class="WHIT">
<span class='line'>619</span> </span><span class="WHIT">  </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>620</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">plugin</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>621</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>622</span> </span><span class="WHIT">  </span><span class="COMM">// 0x010</span><span class="WHIT">
<span class='line'>623</span> </span><span class="WHIT">  </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">id</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">plugin</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>624</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">plugin_types</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>625</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">id</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>626</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">plugins.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">plugin</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>627</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">plugins</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">plugin</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>628</span> </span><span class="WHIT">        </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>629</span> </span><span class="WHIT">          </span><span class="NAME">plugin_types.push</span><span class="PUNC">(</span><span class="NAME">plugins</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">plugin</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>630</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>631</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>632</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>633</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">plugin_types</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>634</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>635</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>636</span> </span></pre></body></html>