You are here

src_minplayer.players.html5.js.html in HTML5 Media 7

  1 /** The minplayer namespace. */
  2 var minplayer = minplayer || {};
  3 
  4 /** All the media player implementations */
  5 minplayer.players = minplayer.players || {};
  6 
  7 /**
  8  * @constructor
  9  * @extends minplayer.display
 10  * @class The HTML5 media player implementation.
 11  *
 12  * @param {object} context The jQuery context.
 13  * @param {object} options This components options.
 14  * @param {object} queue The event queue to pass events around.
 15  */
 16 minplayer.players.html5 = function(context, options, queue) {
 17 
 18   // Derive players base.
 19   minplayer.players.base.call(this, context, options, queue);
 20 };
 21 
 22 /** Derive from minplayer.players.base. */
 23 minplayer.players.html5.prototype = new minplayer.players.base();
 24 
 25 /** Reset the constructor. */
 26 minplayer.players.html5.prototype.constructor = minplayer.players.html5;
 27 
 28 /**
 29  * @see minplayer.players.base#getPriority
 30  * @param {object} file A {@link minplayer.file} object.
 31  * @return {number} The priority of this media player.
 32  */
 33 minplayer.players.html5.getPriority = function(file) {
 34   return 10;
 35 };
 36 
 37 /**
 38  * @see minplayer.players.base#canPlay
 39  * @return {boolean} If this player can play this media type.
 40  */
 41 minplayer.players.html5.canPlay = function(file) {
 42   switch (file.mimetype) {
 43     case 'video/ogg':
 44       return !!minplayer.playTypes.videoOGG;
 45     case 'video/mp4':
 46     case 'video/x-mp4':
 47     case 'video/m4v':
 48     case 'video/x-m4v':
 49       return !!minplayer.playTypes.videoH264;
 50     case 'video/x-webm':
 51     case 'video/webm':
 52     case 'application/octet-stream':
 53       return !!minplayer.playTypes.videoWEBM;
 54     case 'audio/ogg':
 55       return !!minplayer.playTypes.audioOGG;
 56     case 'audio/mpeg':
 57       return !!minplayer.playTypes.audioMP3;
 58     case 'audio/mp4':
 59       return !!minplayer.playTypes.audioMP4;
 60     default:
 61       return false;
 62   }
 63 };
 64 
 65 /**
 66  * @see minplayer.plugin.construct
 67  */
 68 minplayer.players.html5.prototype.construct = function() {
 69 
 70   // Call base constructor.
 71   minplayer.players.base.prototype.construct.call(this);
 72 
 73   // Set the plugin name within the options.
 74   this.options.pluginName = 'html5';
 75 
 76   // Add the player events.
 77   this.addPlayerEvents();
 78 };
 79 
 80 /**
 81  * Adds a new player event.
 82  *
 83  * @param {string} type The type of event being fired.
 84  * @param {function} callback Called when the event is fired.
 85  */
 86 minplayer.players.html5.prototype.addPlayerEvent = function(type, callback) {
 87   if (this.player) {
 88 
 89     // Add an event listener for this event type.
 90     this.player.addEventListener(type, (function(player) {
 91 
 92       // Get the function name.
 93       var func = type + 'Event';
 94 
 95       // If the callback already exists, then remove it from the player.
 96       if (player[func]) {
 97         player.player.removeEventListener(type, player[func], false);
 98       }
 99 
100       // Create a new callback.
101       player[func] = function(event) {
102         callback.call(player, event);
103       };
104 
105       // Return the callback.
106       return player[func];
107 
108     })(this), false);
109   }
110 };
111 
112 /**
113  * Add events.
114  * @return {boolean} If this action was performed.
115  */
116 minplayer.players.html5.prototype.addPlayerEvents = function() {
117 
118   // Check if the player exists.
119   if (this.player) {
120 
121     this.addPlayerEvent('abort', function() {
122       this.trigger('abort');
123     });
124     this.addPlayerEvent('loadstart', function() {
125       this.onReady();
126     });
127     this.addPlayerEvent('loadeddata', function() {
128       this.onLoaded();
129     });
130     this.addPlayerEvent('loadedmetadata', function() {
131       this.onLoaded();
132     });
133     this.addPlayerEvent('canplaythrough', function() {
134       this.onLoaded();
135     });
136     this.addPlayerEvent('ended', function() {
137       this.onComplete();
138     });
139     this.addPlayerEvent('pause', function() {
140       this.onPaused();
141     });
142     this.addPlayerEvent('play', function() {
143       this.onPlaying();
144     });
145     this.addPlayerEvent('playing', function() {
146       this.onPlaying();
147     });
148 
149     var errorSent = false;
150     this.addPlayerEvent('error', function() {
151       if (!errorSent) {
152         errorSent = true;
153         this.trigger('error', 'An error occured - ' + this.player.error.code);
154       }
155     });
156 
157     this.addPlayerEvent('waiting', function() {
158       this.onWaiting();
159     });
160     this.addPlayerEvent('durationchange', function() {
161       this.duration.set(this.player.duration);
162       this.trigger('durationchange', {duration: this.player.duration});
163     });
164     this.addPlayerEvent('progress', function(event) {
165       this.bytesTotal.set(event.total);
166       this.bytesLoaded.set(event.loaded);
167     });
168     return true;
169   }
170 
171   return false;
172 };
173 
174 /**
175  * @see minplayer.players.base#onReady
176  */
177 minplayer.players.html5.prototype.onReady = function() {
178   minplayer.players.base.prototype.onReady.call(this);
179 
180   // Android just say we are loaded here.
181   if (minplayer.isAndroid) {
182     this.onLoaded();
183   }
184 
185   // iOS devices are strange in that they don't autoload.
186   if (minplayer.isIDevice) {
187     this.play();
188     setTimeout((function(player) {
189       return function() {
190         player.pause();
191         player.onLoaded();
192       };
193     })(this), 1);
194   }
195 };
196 
197 /**
198  * @see minplayer.players.base#playerFound
199  * @return {boolean} TRUE - if the player is in the DOM, FALSE otherwise.
200  */
201 minplayer.players.html5.prototype.playerFound = function() {
202   return (this.display.find(this.mediaFile.type).length > 0);
203 };
204 
205 /**
206  * @see minplayer.players.base#create
207  * @return {object} The media player entity.
208  */
209 minplayer.players.html5.prototype.create = function() {
210   minplayer.players.base.prototype.create.call(this);
211   var element = jQuery(document.createElement(this.mediaFile.type))
212   .attr(this.options.attributes)
213   .append(
214     jQuery(document.createElement('source')).attr({
215       'src': this.mediaFile.path
216     })
217   );
218 
219   // Fix the fluid width and height.
220   element.eq(0)[0].setAttribute('width', '100%');
221   element.eq(0)[0].setAttribute('height', '100%');
222   element.eq(0)[0].setAttribute('autobuffer', true);
223   var option = this.options.autoload ? 'auto' : 'metadata';
224   option = minplayer.isIDevice ? 'metadata' : option;
225   element.eq(0)[0].setAttribute('preload', option);
226   return element;
227 };
228 
229 /**
230  * @see minplayer.players.base#getPlayer
231  * @return {object} The media player object.
232  */
233 minplayer.players.html5.prototype.getPlayer = function() {
234   return this.elements.media.eq(0)[0];
235 };
236 
237 /**
238  * @see minplayer.players.base#load
239  * @return {boolean} If this action was performed.
240  */
241 minplayer.players.html5.prototype.load = function(file) {
242 
243   // See if a load is even necessary.
244   if (minplayer.players.base.prototype.load.call(this, file)) {
245 
246     // Get the current source.
247     var src = this.elements.media.attr('src');
248     if (!src) {
249       src = jQuery('source', this.elements.media).eq(0).attr('src');
250     }
251 
252     // Only swap out if the new file is different from the source.
253     if (src != file.path) {
254 
255       // Add a new player.
256       this.addPlayer();
257 
258       // Set the new player.
259       this.player = this.getPlayer();
260 
261       // Add the events again.
262       this.addPlayerEvents();
263 
264       // Change the source...
265       var code = '<source src="' + file.path + '"></source>';
266       this.elements.media.removeAttr('src').empty().html(code);
267       return true;
268     }
269   }
270 
271   return false;
272 };
273 
274 /**
275  * @see minplayer.players.base#play
276  * @return {boolean} If this action was performed.
277  */
278 minplayer.players.html5.prototype.play = function() {
279   if (minplayer.players.base.prototype.play.call(this)) {
280     this.player.play();
281     return true;
282   }
283 
284   return false;
285 };
286 
287 /**
288  * @see minplayer.players.base#pause
289  * @return {boolean} If this action was performed.
290  */
291 minplayer.players.html5.prototype.pause = function() {
292   if (minplayer.players.base.prototype.pause.call(this)) {
293     this.player.pause();
294     return true;
295   }
296 
297   return false;
298 };
299 
300 /**
301  * @see minplayer.players.base#stop
302  * @return {boolean} If this action was performed.
303  */
304 minplayer.players.html5.prototype.stop = function() {
305   if (minplayer.players.base.prototype.stop.call(this)) {
306     this.player.pause();
307     this.player.src = '';
308     return true;
309   }
310 
311   return false;
312 };
313 
314 /**
315  * @see minplayer.players.base#seek
316  * @return {boolean} If this action was performed.
317  */
318 minplayer.players.html5.prototype.seek = function(pos) {
319   if (minplayer.players.base.prototype.seek.call(this, pos)) {
320     this.player.currentTime = pos;
321     return true;
322   }
323 
324   return false;
325 };
326 
327 /**
328  * @see minplayer.players.base#setVolume
329  * @return {boolean} If this action was performed.
330  */
331 minplayer.players.html5.prototype.setVolume = function(vol) {
332   if (minplayer.players.base.prototype.setVolume.call(this, vol)) {
333     this.player.volume = vol;
334     return true;
335   }
336 
337   return false;
338 };
339 
340 /**
341  * @see minplayer.players.base#getVolume
342  */
343 minplayer.players.html5.prototype.getVolume = function(callback) {
344   if (this.isReady()) {
345     callback(this.player.volume);
346   }
347 };
348 
349 /**
350  * @see minplayer.players.base#getDuration
351  */
352 minplayer.players.html5.prototype.getDuration = function(callback) {
353   if (this.isReady()) {
354     callback(this.player.duration);
355   }
356 };
357 
358 /**
359  * @see minplayer.players.base#getCurrentTime
360  */
361 minplayer.players.html5.prototype.getCurrentTime = function(callback) {
362   if (this.isReady()) {
363     callback(this.player.currentTime);
364   }
365 };
366 
367 /**
368  * @see minplayer.players.base#getBytesLoaded
369  */
370 minplayer.players.html5.prototype.getBytesLoaded = function(callback) {
371   if (this.isReady()) {
372     var loaded = 0;
373 
374     // Check several different possibilities.
375     if (this.bytesLoaded.value) {
376       loaded = this.bytesLoaded.value;
377     }
378     else if (this.player.buffered &&
379         this.player.buffered.length > 0 &&
380         this.player.buffered.end &&
381         this.player.duration) {
382       loaded = this.player.buffered.end(0);
383     }
384     else if (this.player.bytesTotal != undefined &&
385              this.player.bytesTotal > 0 &&
386              this.player.bufferedBytes != undefined) {
387       loaded = this.player.bufferedBytes;
388     }
389 
390     // Return the loaded amount.
391     callback(loaded);
392   }
393 };
394 
395 /**
396  * @see minplayer.players.base#getBytesTotal
397  */
398 minplayer.players.html5.prototype.getBytesTotal = function(callback) {
399   if (this.isReady()) {
400 
401     var total = 0;
402 
403     // Check several different possibilities.
404     if (this.bytesTotal.value) {
405       total = this.bytesTotal.value;
406     }
407     else if (this.player.buffered &&
408         this.player.buffered.length > 0 &&
409         this.player.buffered.end &&
410         this.player.duration) {
411       total = this.player.duration;
412     }
413     else if (this.player.bytesTotal != undefined &&
414              this.player.bytesTotal > 0 &&
415              this.player.bufferedBytes != undefined) {
416       total = this.player.bytesTotal;
417     }
418 
419     // Return the loaded amount.
420     callback(total);
421   }
422 };
423 

File

player/doc/symbols/src/src_minplayer.players.html5.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="KEYW">var</span><span class="WHIT"> </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">/** All the media player implementations */</span><span class="WHIT">
<span class='line'>  5</span> </span><span class="NAME">minplayer.players</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">minplayer.players</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">/**
<span class='line'>  8</span>  * @constructor
<span class='line'>  9</span>  * @extends minplayer.display
<span class='line'> 10</span>  * @class The HTML5 media player implementation.
<span class='line'> 11</span>  *
<span class='line'> 12</span>  * @param {object} context The jQuery context.
<span class='line'> 13</span>  * @param {object} options This components options.
<span class='line'> 14</span>  * @param {object} queue The event queue to pass events around.
<span class='line'> 15</span>  */</span><span class="WHIT">
<span class='line'> 16</span> </span><span class="NAME">minplayer.players.html5</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">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'> 17</span> 
<span class='line'> 18</span> </span><span class="WHIT">  </span><span class="COMM">// Derive players base.</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT">  </span><span class="NAME">minplayer.players.base.call</span><span class="PUNC">(</span><span class="KEYW">this</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="PUNC">;</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 21</span> 
<span class='line'> 22</span> </span><span class="COMM">/** Derive from minplayer.players.base. */</span><span class="WHIT">
<span class='line'> 23</span> </span><span class="NAME">minplayer.players.html5.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">minplayer.players.base</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 24</span> 
<span class='line'> 25</span> </span><span class="COMM">/** Reset the constructor. */</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="NAME">minplayer.players.html5.prototype.constructor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">minplayer.players.html5</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 27</span> 
<span class='line'> 28</span> </span><span class="COMM">/**
<span class='line'> 29</span>  * @see minplayer.players.base#getPriority
<span class='line'> 30</span>  * @param {object} file A {@link minplayer.file} object.
<span class='line'> 31</span>  * @return {number} The priority of this media player.
<span class='line'> 32</span>  */</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="NAME">minplayer.players.html5.getPriority</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">file</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 36</span> 
<span class='line'> 37</span> </span><span class="COMM">/**
<span class='line'> 38</span>  * @see minplayer.players.base#canPlay
<span class='line'> 39</span>  * @return {boolean} If this player can play this media type.
<span class='line'> 40</span>  */</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="NAME">minplayer.players.html5.canPlay</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">file</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">  </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">file.mimetype</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'video/ogg'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 44</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">minplayer.playTypes.videoOGG</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'video/mp4'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'video/x-mp4'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'video/m4v'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'video/x-m4v'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 49</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">minplayer.playTypes.videoH264</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'video/x-webm'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'video/webm'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'application/octet-stream'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 53</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">minplayer.playTypes.videoWEBM</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'audio/ogg'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 55</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">minplayer.playTypes.audioOGG</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'audio/mpeg'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 57</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">minplayer.playTypes.audioMP3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">    </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'audio/mp4'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 59</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">minplayer.playTypes.audioMP4</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">    </span><span class="KEYW">default</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 61</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'> 62</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> 
<span class='line'> 65</span> </span><span class="COMM">/**
<span class='line'> 66</span>  * @see minplayer.plugin.construct
<span class='line'> 67</span>  */</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="NAME">minplayer.players.html5.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'> 69</span> 
<span class='line'> 70</span> </span><span class="WHIT">  </span><span class="COMM">// Call base constructor.</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">  </span><span class="NAME">minplayer.players.base.prototype.construct.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> 
<span class='line'> 73</span> </span><span class="WHIT">  </span><span class="COMM">// Set the plugin name within the options.</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">  </span><span class="NAME">this.options.pluginName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'html5'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 75</span> 
<span class='line'> 76</span> </span><span class="WHIT">  </span><span class="COMM">// Add the player events.</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">  </span><span class="NAME">this.addPlayerEvents</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 79</span> 
<span class='line'> 80</span> </span><span class="COMM">/**
<span class='line'> 81</span>  * Adds a new player event.
<span class='line'> 82</span>  *
<span class='line'> 83</span>  * @param {string} type The type of event being fired.
<span class='line'> 84</span>  * @param {function} callback Called when the event is fired.
<span class='line'> 85</span>  */</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="NAME">minplayer.players.html5.prototype.addPlayerEvent</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">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.player</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 88</span> 
<span class='line'> 89</span> </span><span class="WHIT">    </span><span class="COMM">// Add an event listener for this event type.</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">    </span><span class="NAME">this.player.addEventListener</span><span class="PUNC">(</span><span class="NAME">type</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">player</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 91</span> 
<span class='line'> 92</span> </span><span class="WHIT">      </span><span class="COMM">// Get the function name.</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'Event'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> 
<span class='line'> 95</span> </span><span class="WHIT">      </span><span class="COMM">// If the callback already exists, then remove it from the player.</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">player</span><span class="PUNC">[</span><span class="NAME">func</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">        </span><span class="NAME">player.player.removeEventListener</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">player</span><span class="PUNC">[</span><span class="NAME">func</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 99</span> 
<span class='line'>100</span> </span><span class="WHIT">      </span><span class="COMM">// Create a new callback.</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">      </span><span class="NAME">player</span><span class="PUNC">[</span><span class="NAME">func</span><span class="PUNC">]</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="PUNC">{</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">        </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">player</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">      </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">// Return the callback.</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">player</span><span class="PUNC">[</span><span class="NAME">func</span><span class="PUNC">]</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="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="KEYW">false</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><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>111</span> 
<span class='line'>112</span> </span><span class="COMM">/**
<span class='line'>113</span>  * Add events.
<span class='line'>114</span>  * @return {boolean} If this action was performed.
<span class='line'>115</span>  */</span><span class="WHIT">
<span class='line'>116</span> </span><span class="NAME">minplayer.players.html5.prototype.addPlayerEvents</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'>117</span> 
<span class='line'>118</span> </span><span class="WHIT">  </span><span class="COMM">// Check if the player exists.</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.player</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>120</span> 
<span class='line'>121</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'abort'</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'>122</span> </span><span class="WHIT">      </span><span class="NAME">this.trigger</span><span class="PUNC">(</span><span class="STRN">'abort'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'loadstart'</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'>125</span> </span><span class="WHIT">      </span><span class="NAME">this.onReady</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'loadeddata'</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'>128</span> </span><span class="WHIT">      </span><span class="NAME">this.onLoaded</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'loadedmetadata'</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'>131</span> </span><span class="WHIT">      </span><span class="NAME">this.onLoaded</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'canplaythrough'</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'>134</span> </span><span class="WHIT">      </span><span class="NAME">this.onLoaded</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'ended'</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'>137</span> </span><span class="WHIT">      </span><span class="NAME">this.onComplete</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'pause'</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'>140</span> </span><span class="WHIT">      </span><span class="NAME">this.onPaused</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="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'play'</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'>143</span> </span><span class="WHIT">      </span><span class="NAME">this.onPlaying</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'playing'</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'>146</span> </span><span class="WHIT">      </span><span class="NAME">this.onPlaying</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>148</span> 
<span class='line'>149</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">errorSent</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'>150</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'error'</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'>151</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">errorSent</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">        </span><span class="NAME">errorSent</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'>153</span> </span><span class="WHIT">        </span><span class="NAME">this.trigger</span><span class="PUNC">(</span><span class="STRN">'error'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'An error occured - '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.player.error.code</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>156</span> 
<span class='line'>157</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'waiting'</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'>158</span> </span><span class="WHIT">      </span><span class="NAME">this.onWaiting</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'durationchange'</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'>161</span> </span><span class="WHIT">      </span><span class="NAME">this.duration.set</span><span class="PUNC">(</span><span class="NAME">this.player.duration</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">      </span><span class="NAME">this.trigger</span><span class="PUNC">(</span><span class="STRN">'durationchange'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">duration</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.player.duration</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">    </span><span class="NAME">this.addPlayerEvent</span><span class="PUNC">(</span><span class="STRN">'progress'</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="PUNC">{</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">      </span><span class="NAME">this.bytesTotal.set</span><span class="PUNC">(</span><span class="NAME">event.total</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">      </span><span class="NAME">this.bytesLoaded.set</span><span class="PUNC">(</span><span class="NAME">event.loaded</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>170</span> 
<span class='line'>171</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'>172</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>173</span> 
<span class='line'>174</span> </span><span class="COMM">/**
<span class='line'>175</span>  * @see minplayer.players.base#onReady
<span class='line'>176</span>  */</span><span class="WHIT">
<span class='line'>177</span> </span><span class="NAME">minplayer.players.html5.prototype.onReady</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'>178</span> </span><span class="WHIT">  </span><span class="NAME">minplayer.players.base.prototype.onReady.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>179</span> 
<span class='line'>180</span> </span><span class="WHIT">  </span><span class="COMM">// Android just say we are loaded here.</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">minplayer.isAndroid</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">    </span><span class="NAME">this.onLoaded</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>184</span> 
<span class='line'>185</span> </span><span class="WHIT">  </span><span class="COMM">// iOS devices are strange in that they don't autoload.</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">minplayer.isIDevice</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">    </span><span class="NAME">this.play</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>188</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">player</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>189</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'>190</span> </span><span class="WHIT">        </span><span class="NAME">player.pause</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">        </span><span class="NAME">player.onLoaded</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>193</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">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>195</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>196</span> 
<span class='line'>197</span> </span><span class="COMM">/**
<span class='line'>198</span>  * @see minplayer.players.base#playerFound
<span class='line'>199</span>  * @return {boolean} TRUE - if the player is in the DOM, FALSE otherwise.
<span class='line'>200</span>  */</span><span class="WHIT">
<span class='line'>201</span> </span><span class="NAME">minplayer.players.html5.prototype.playerFound</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'>202</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.display.find</span><span class="PUNC">(</span><span class="NAME">this.mediaFile.type</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">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'>203</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span> 
<span class='line'>205</span> </span><span class="COMM">/**
<span class='line'>206</span>  * @see minplayer.players.base#create
<span class='line'>207</span>  * @return {object} The media player entity.
<span class='line'>208</span>  */</span><span class="WHIT">
<span class='line'>209</span> </span><span class="NAME">minplayer.players.html5.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="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">  </span><span class="NAME">minplayer.players.base.prototype.create.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">element</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">document.createElement</span><span class="PUNC">(</span><span class="NAME">this.mediaFile.type</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT">  </span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="NAME">this.options.attributes</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">  </span><span class="PUNC">.</span><span class="NAME">append</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">    </span><span class="NAME">jQuery</span><span class="PUNC">(</span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">'source'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">      </span><span class="STRN">'src'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.mediaFile.path</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">  </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> 
<span class='line'>219</span> </span><span class="WHIT">  </span><span class="COMM">// Fix the fluid width and height.</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">  </span><span class="NAME">element.eq</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">setAttribute</span><span class="PUNC">(</span><span class="STRN">'width'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'100%'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">  </span><span class="NAME">element.eq</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">setAttribute</span><span class="PUNC">(</span><span class="STRN">'height'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'100%'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">  </span><span class="NAME">element.eq</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">setAttribute</span><span class="PUNC">(</span><span class="STRN">'autobuffer'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">option</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.options.autoload</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'auto'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'metadata'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT">  </span><span class="NAME">option</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">minplayer.isIDevice</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'metadata'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">option</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT">  </span><span class="NAME">element.eq</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">setAttribute</span><span class="PUNC">(</span><span class="STRN">'preload'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">option</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>226</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">element</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>227</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>228</span> 
<span class='line'>229</span> </span><span class="COMM">/**
<span class='line'>230</span>  * @see minplayer.players.base#getPlayer
<span class='line'>231</span>  * @return {object} The media player object.
<span class='line'>232</span>  */</span><span class="WHIT">
<span class='line'>233</span> </span><span class="NAME">minplayer.players.html5.prototype.getPlayer</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'>234</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.elements.media.eq</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>235</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>236</span> 
<span class='line'>237</span> </span><span class="COMM">/**
<span class='line'>238</span>  * @see minplayer.players.base#load
<span class='line'>239</span>  * @return {boolean} If this action was performed.
<span class='line'>240</span>  */</span><span class="WHIT">
<span class='line'>241</span> </span><span class="NAME">minplayer.players.html5.prototype.load</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">file</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>242</span> 
<span class='line'>243</span> </span><span class="WHIT">  </span><span class="COMM">// See if a load is even necessary.</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">minplayer.players.base.prototype.load.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">file</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>245</span> 
<span class='line'>246</span> </span><span class="WHIT">    </span><span class="COMM">// Get the current source.</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">src</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.elements.media.attr</span><span class="PUNC">(</span><span class="STRN">'src'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>248</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">src</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT">      </span><span class="NAME">src</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jQuery</span><span class="PUNC">(</span><span class="STRN">'source'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.elements.media</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">eq</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="STRN">'src'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>250</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>251</span> 
<span class='line'>252</span> </span><span class="WHIT">    </span><span class="COMM">// Only swap out if the new file is different from the source.</span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">src</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">file.path</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>254</span> 
<span class='line'>255</span> </span><span class="WHIT">      </span><span class="COMM">// Add a new player.</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">      </span><span class="NAME">this.addPlayer</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>257</span> 
<span class='line'>258</span> </span><span class="WHIT">      </span><span class="COMM">// Set the new player.</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT">      </span><span class="NAME">this.player</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.getPlayer</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>260</span> 
<span class='line'>261</span> </span><span class="WHIT">      </span><span class="COMM">// Add the events again.</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">      </span><span class="NAME">this.addPlayerEvents</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>263</span> 
<span class='line'>264</span> </span><span class="WHIT">      </span><span class="COMM">// Change the source...</span><span class="WHIT">
<span class='line'>265</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">code</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;source src="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">file.path</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'">&lt;/source>'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">      </span><span class="NAME">this.elements.media.removeAttr</span><span class="PUNC">(</span><span class="STRN">'src'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">empty</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">html</span><span class="PUNC">(</span><span class="NAME">code</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</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="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>272</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>273</span> 
<span class='line'>274</span> </span><span class="COMM">/**
<span class='line'>275</span>  * @see minplayer.players.base#play
<span class='line'>276</span>  * @return {boolean} If this action was performed.
<span class='line'>277</span>  */</span><span class="WHIT">
<span class='line'>278</span> </span><span class="NAME">minplayer.players.html5.prototype.play</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'>279</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">minplayer.players.base.prototype.play.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">    </span><span class="NAME">this.player.play</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>283</span> 
<span class='line'>284</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'>285</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>286</span> 
<span class='line'>287</span> </span><span class="COMM">/**
<span class='line'>288</span>  * @see minplayer.players.base#pause
<span class='line'>289</span>  * @return {boolean} If this action was performed.
<span class='line'>290</span>  */</span><span class="WHIT">
<span class='line'>291</span> </span><span class="NAME">minplayer.players.html5.prototype.pause</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'>292</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">minplayer.players.base.prototype.pause.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">    </span><span class="NAME">this.player.pause</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>296</span> 
<span class='line'>297</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'>298</span> </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="COMM">/**
<span class='line'>301</span>  * @see minplayer.players.base#stop
<span class='line'>302</span>  * @return {boolean} If this action was performed.
<span class='line'>303</span>  */</span><span class="WHIT">
<span class='line'>304</span> </span><span class="NAME">minplayer.players.html5.prototype.stop</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'>305</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">minplayer.players.base.prototype.stop.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT">    </span><span class="NAME">this.player.pause</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">    </span><span class="NAME">this.player.src</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</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 class='line'>311</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'>312</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>313</span> 
<span class='line'>314</span> </span><span class="COMM">/**
<span class='line'>315</span>  * @see minplayer.players.base#seek
<span class='line'>316</span>  * @return {boolean} If this action was performed.
<span class='line'>317</span>  */</span><span class="WHIT">
<span class='line'>318</span> </span><span class="NAME">minplayer.players.html5.prototype.seek</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">pos</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>319</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">minplayer.players.base.prototype.seek.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>320</span> </span><span class="WHIT">    </span><span class="NAME">this.player.currentTime</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>321</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>322</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>323</span> 
<span class='line'>324</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'>325</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>326</span> 
<span class='line'>327</span> </span><span class="COMM">/**
<span class='line'>328</span>  * @see minplayer.players.base#setVolume
<span class='line'>329</span>  * @return {boolean} If this action was performed.
<span class='line'>330</span>  */</span><span class="WHIT">
<span class='line'>331</span> </span><span class="NAME">minplayer.players.html5.prototype.setVolume</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">vol</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>332</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">minplayer.players.base.prototype.setVolume.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">vol</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>333</span> </span><span class="WHIT">    </span><span class="NAME">this.player.volume</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">vol</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>336</span> 
<span class='line'>337</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'>338</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>339</span> 
<span class='line'>340</span> </span><span class="COMM">/**
<span class='line'>341</span>  * @see minplayer.players.base#getVolume
<span class='line'>342</span>  */</span><span class="WHIT">
<span class='line'>343</span> </span><span class="NAME">minplayer.players.html5.prototype.getVolume</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="PUNC">{</span><span class="WHIT">
<span class='line'>344</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.isReady</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'>345</span> </span><span class="WHIT">    </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">this.player.volume</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>346</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>347</span> </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="COMM">/**
<span class='line'>350</span>  * @see minplayer.players.base#getDuration
<span class='line'>351</span>  */</span><span class="WHIT">
<span class='line'>352</span> </span><span class="NAME">minplayer.players.html5.prototype.getDuration</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="PUNC">{</span><span class="WHIT">
<span class='line'>353</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.isReady</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'>354</span> </span><span class="WHIT">    </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">this.player.duration</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>355</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>356</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>357</span> 
<span class='line'>358</span> </span><span class="COMM">/**
<span class='line'>359</span>  * @see minplayer.players.base#getCurrentTime
<span class='line'>360</span>  */</span><span class="WHIT">
<span class='line'>361</span> </span><span class="NAME">minplayer.players.html5.prototype.getCurrentTime</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="PUNC">{</span><span class="WHIT">
<span class='line'>362</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.isReady</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'>363</span> </span><span class="WHIT">    </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">this.player.currentTime</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>364</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>365</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>366</span> 
<span class='line'>367</span> </span><span class="COMM">/**
<span class='line'>368</span>  * @see minplayer.players.base#getBytesLoaded
<span class='line'>369</span>  */</span><span class="WHIT">
<span class='line'>370</span> </span><span class="NAME">minplayer.players.html5.prototype.getBytesLoaded</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="PUNC">{</span><span class="WHIT">
<span class='line'>371</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.isReady</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'>372</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">loaded</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 class='line'>373</span> 
<span class='line'>374</span> </span><span class="WHIT">    </span><span class="COMM">// Check several different possibilities.</span><span class="WHIT">
<span class='line'>375</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.bytesLoaded.value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">      </span><span class="NAME">loaded</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.bytesLoaded.value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>377</span> </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">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.player.buffered</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">this.player.buffered.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT">        </span><span class="NAME">this.player.buffered.end</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">        </span><span class="NAME">this.player.duration</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">      </span><span class="NAME">loaded</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.player.buffered.end</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>383</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>384</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">this.player.bytesTotal</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>385</span> </span><span class="WHIT">             </span><span class="NAME">this.player.bytesTotal</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>386</span> </span><span class="WHIT">             </span><span class="NAME">this.player.bufferedBytes</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>387</span> </span><span class="WHIT">      </span><span class="NAME">loaded</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.player.bufferedBytes</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>388</span> </span><span class="WHIT">    </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="COMM">// Return the loaded amount.</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT">    </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">loaded</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="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>394</span> 
<span class='line'>395</span> </span><span class="COMM">/**
<span class='line'>396</span>  * @see minplayer.players.base#getBytesTotal
<span class='line'>397</span>  */</span><span class="WHIT">
<span class='line'>398</span> </span><span class="NAME">minplayer.players.html5.prototype.getBytesTotal</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="PUNC">{</span><span class="WHIT">
<span class='line'>399</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.isReady</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'>400</span> 
<span class='line'>401</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">total</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 class='line'>402</span> 
<span class='line'>403</span> </span><span class="WHIT">    </span><span class="COMM">// Check several different possibilities.</span><span class="WHIT">
<span class='line'>404</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.bytesTotal.value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>405</span> </span><span class="WHIT">      </span><span class="NAME">total</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.bytesTotal.value</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="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.player.buffered</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>408</span> </span><span class="WHIT">        </span><span class="NAME">this.player.buffered.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>409</span> </span><span class="WHIT">        </span><span class="NAME">this.player.buffered.end</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>410</span> </span><span class="WHIT">        </span><span class="NAME">this.player.duration</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>411</span> </span><span class="WHIT">      </span><span class="NAME">total</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.player.duration</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>412</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>413</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">this.player.bytesTotal</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>414</span> </span><span class="WHIT">             </span><span class="NAME">this.player.bytesTotal</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>415</span> </span><span class="WHIT">             </span><span class="NAME">this.player.bufferedBytes</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>416</span> </span><span class="WHIT">      </span><span class="NAME">total</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.player.bytesTotal</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>417</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>418</span> 
<span class='line'>419</span> </span><span class="WHIT">    </span><span class="COMM">// Return the loaded amount.</span><span class="WHIT">
<span class='line'>420</span> </span><span class="WHIT">    </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">total</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>421</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>422</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>423</span> </span></pre></body></html>