]> source.dussan.org Git - nextcloud-server.git/commitdiff
add jplayer source
authorRobin Appelman <icewind1991@gmail.com>
Sun, 1 Jan 2012 22:41:30 +0000 (23:41 +0100)
committerRobin Appelman <icewind1991@gmail.com>
Sun, 1 Jan 2012 22:48:38 +0000 (23:48 +0100)
apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.as [new file with mode: 0644]
apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.fla [new file with mode: 0644]
apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jplayer.playlist.js [new file with mode: 0644]
apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jquery.jplayer.inspector.js [new file with mode: 0644]
apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerEvent.as [new file with mode: 0644]
apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp3.as [new file with mode: 0644]
apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp4.as [new file with mode: 0644]
apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerStatus.as [new file with mode: 0644]
apps/media/js/jQuery.jPlayer.2.1.0.source/jquery.jplayer.js [new file with mode: 0644]

diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.as b/apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.as
new file mode 100644 (file)
index 0000000..1178dac
--- /dev/null
@@ -0,0 +1,415 @@
+/*\r
+ * jPlayer Plugin for jQuery JavaScript Library\r
+ * http://www.happyworm.com/jquery/jplayer\r
+ *\r
+ * Copyright (c) 2009 - 2011 Happyworm Ltd\r
+ * Dual licensed under the MIT and GPL licenses.\r
+ *  - http://www.opensource.org/licenses/mit-license.php\r
+ *  - http://www.gnu.org/copyleft/gpl.html\r
+ *\r
+ * Author: Mark J Panaghiston\r
+ * Version: 2.1.0\r
+ * Date: 1st September 2011\r
+ *\r
+ * FlashVars expected: (AS3 property of: loaderInfo.parameters)\r
+ *     id:     (URL Encoded: String) Id of jPlayer instance\r
+ *     vol:    (Number) Sets the initial volume\r
+ *     muted:  (Boolean in a String) Sets the initial muted state\r
+ *     jQuery: (URL Encoded: String) Sets the jQuery var name. Used with: someVar = jQuery.noConflict(true);\r
+ *\r
+ * Compiled using: Adobe Flex Compiler (mxmlc) Version 4.5.1 build 21328\r
+ */\r
+\r
+package {\r
+       import flash.system.Security;\r
+       import flash.external.ExternalInterface;\r
+\r
+       import flash.utils.Timer;\r
+       import flash.events.TimerEvent;\r
+       \r
+       import flash.text.TextField;\r
+       import flash.text.TextFormat;\r
+\r
+       import flash.events.KeyboardEvent;\r
+\r
+       import flash.display.Sprite;\r
+       import happyworm.jPlayer.*;\r
+\r
+       import flash.display.StageAlign;\r
+       import flash.display.StageScaleMode;\r
+       import flash.events.Event;\r
+       import flash.events.MouseEvent;\r
+\r
+       import flash.ui.ContextMenu;\r
+       import flash.ui.ContextMenuItem;\r
+       import flash.events.ContextMenuEvent;\r
+       import flash.net.URLRequest;\r
+       import flash.net.navigateToURL;\r
+\r
+       public class Jplayer extends Sprite {\r
+               private var jQuery:String;\r
+               private var sentNumberFractionDigits:uint = 2;\r
+\r
+               public var commonStatus:JplayerStatus = new JplayerStatus(); // Used for inital ready event so volume is correct.\r
+\r
+               private var myInitTimer:Timer = new Timer(100, 0);\r
+\r
+               private var myMp3Player:JplayerMp3;\r
+               private var myMp4Player:JplayerMp4;\r
+\r
+               private var isMp3:Boolean = false;\r
+               private var isVideo:Boolean = false;\r
+\r
+               private var txLog:TextField;\r
+               private var debug:Boolean = false; // Set debug to false for release compile!\r
+\r
+               public function Jplayer() {\r
+                       flash.system.Security.allowDomain("*");\r
+\r
+                       jQuery = loaderInfo.parameters.jQuery + "('#" + loaderInfo.parameters.id + "').jPlayer";\r
+                       commonStatus.volume = Number(loaderInfo.parameters.vol);\r
+                       commonStatus.muted = loaderInfo.parameters.muted == "true";\r
+\r
+                       stage.scaleMode = StageScaleMode.NO_SCALE;\r
+                       stage.align = StageAlign.TOP_LEFT;\r
+                       stage.addEventListener(Event.RESIZE, resizeHandler);\r
+                       stage.addEventListener(MouseEvent.CLICK, clickHandler);\r
+\r
+                       var initialVolume:Number = commonStatus.volume;\r
+                       if(commonStatus.muted) {\r
+                               initialVolume = 0;\r
+                       }\r
+                       myMp3Player = new JplayerMp3(initialVolume);\r
+                       addChild(myMp3Player);\r
+\r
+                       myMp4Player = new JplayerMp4(initialVolume);\r
+                       addChild(myMp4Player);\r
+\r
+                       setupListeners(!isMp3, isMp3); // Set up the listeners to the default isMp3 state.\r
+\r
+                       // The ContextMenu only partially works. The menu select events never occur.\r
+                       // Investigated and it is something to do with the way jPlayer inserts the Flash on the page.\r
+                       // A simple test inserting the Jplayer.swf on a page using: 1) SWFObject 2.2 works. 2) AC_FL_RunContent() works.\r
+                       // jPlayer Flash insertion is based on SWFObject 2.2 and the resaon behind this failure is not clear. The Flash insertion HTML on the page looks similar.\r
+                       var myContextMenu:ContextMenu = new ContextMenu();\r
+                       myContextMenu.hideBuiltInItems();\r
+                       var menuItem_jPlayer:ContextMenuItem = new ContextMenuItem("jPlayer " + JplayerStatus.VERSION);\r
+                       var menuItem_happyworm:ContextMenuItem = new ContextMenuItem("© 2009-2011 Happyworm Ltd", true);\r
+                       menuItem_jPlayer.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuSelectHandler_jPlayer);\r
+                       menuItem_happyworm.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuSelectHandler_happyworm);\r
+                       myContextMenu.customItems.push(menuItem_jPlayer, menuItem_happyworm);\r
+                       contextMenu = myContextMenu;\r
+\r
+                       // Log console for dev compile option: debug\r
+                       if(debug) {\r
+                               txLog = new TextField();\r
+                               txLog.x = 5;\r
+                               txLog.y = 5;\r
+                               txLog.width = 540;\r
+                               txLog.height = 390;\r
+                               txLog.border = true;\r
+                               txLog.background = true;\r
+                               txLog.backgroundColor = 0xEEEEFF;\r
+                               txLog.multiline = true;\r
+                               txLog.text = "jPlayer " + JplayerStatus.VERSION;\r
+                               txLog.visible = false;\r
+                               this.addChild(txLog);\r
+                               this.stage.addEventListener(KeyboardEvent.KEY_UP, keyboardHandler);\r
+\r
+                               myMp3Player.addEventListener(JplayerEvent.DEBUG_MSG, debugMsgHandler);\r
+                               myMp4Player.addEventListener(JplayerEvent.DEBUG_MSG, debugMsgHandler);\r
+                       }\r
+\r
+                       // Delay init() because Firefox 3.5.7+ developed a bug with local testing in Firebug.\r
+                       myInitTimer.addEventListener(TimerEvent.TIMER, init);\r
+                       myInitTimer.start();\r
+               }\r
+               \r
+               private function init(e:TimerEvent):void {\r
+                       myInitTimer.stop();\r
+                       if(ExternalInterface.available) {\r
+                               ExternalInterface.addCallback("fl_setAudio_mp3", fl_setAudio_mp3);\r
+                               ExternalInterface.addCallback("fl_setAudio_m4a", fl_setAudio_m4a);\r
+                               ExternalInterface.addCallback("fl_setVideo_m4v", fl_setVideo_m4v);\r
+                               ExternalInterface.addCallback("fl_clearMedia", fl_clearMedia);\r
+                               ExternalInterface.addCallback("fl_load", fl_load);\r
+                               ExternalInterface.addCallback("fl_play", fl_play);\r
+                               ExternalInterface.addCallback("fl_pause", fl_pause);\r
+                               ExternalInterface.addCallback("fl_play_head", fl_play_head);\r
+                               ExternalInterface.addCallback("fl_volume", fl_volume);\r
+                               ExternalInterface.addCallback("fl_mute", fl_mute);\r
+\r
+                               ExternalInterface.call(jQuery, "jPlayerFlashEvent", JplayerEvent.JPLAYER_READY, extractStatusData(commonStatus)); // See JplayerStatus() class for version number.\r
+                       }\r
+               }\r
+               private function setupListeners(oldMP3:Boolean, newMP3:Boolean):void {\r
+                       if(oldMP3 != newMP3) {\r
+                               if(newMP3) {\r
+                                       listenToMp3(true);\r
+                                       listenToMp4(false);\r
+                               } else {\r
+                                       listenToMp3(false);\r
+                                       listenToMp4(true);\r
+                               }\r
+                       }\r
+               }\r
+               private function listenToMp3(active:Boolean):void {\r
+                       if(active) {\r
+                               myMp3Player.addEventListener(JplayerEvent.JPLAYER_ERROR, jPlayerFlashEvent);\r
+                               myMp3Player.addEventListener(JplayerEvent.JPLAYER_PROGRESS, jPlayerFlashEvent);\r
+                               myMp3Player.addEventListener(JplayerEvent.JPLAYER_TIMEUPDATE, jPlayerFlashEvent);\r
+                               myMp3Player.addEventListener(JplayerEvent.JPLAYER_ENDED, jPlayerFlashEvent);\r
+                               \r
+                               myMp3Player.addEventListener(JplayerEvent.JPLAYER_PLAY, jPlayerFlashEvent);\r
+                               myMp3Player.addEventListener(JplayerEvent.JPLAYER_PAUSE, jPlayerFlashEvent);\r
+                               myMp3Player.addEventListener(JplayerEvent.JPLAYER_LOADSTART, jPlayerFlashEvent);\r
+\r
+                               myMp3Player.addEventListener(JplayerEvent.JPLAYER_SEEKING, jPlayerFlashEvent);\r
+                               myMp3Player.addEventListener(JplayerEvent.JPLAYER_SEEKED, jPlayerFlashEvent);\r
+                       } else {\r
+                               myMp3Player.removeEventListener(JplayerEvent.JPLAYER_ERROR, jPlayerFlashEvent);\r
+                               myMp3Player.removeEventListener(JplayerEvent.JPLAYER_PROGRESS, jPlayerFlashEvent);\r
+                               myMp3Player.removeEventListener(JplayerEvent.JPLAYER_TIMEUPDATE, jPlayerFlashEvent);\r
+                               myMp3Player.removeEventListener(JplayerEvent.JPLAYER_ENDED, jPlayerFlashEvent);\r
+                               \r
+                               myMp3Player.removeEventListener(JplayerEvent.JPLAYER_PLAY, jPlayerFlashEvent);\r
+                               myMp3Player.removeEventListener(JplayerEvent.JPLAYER_PAUSE, jPlayerFlashEvent);\r
+                               myMp3Player.removeEventListener(JplayerEvent.JPLAYER_LOADSTART, jPlayerFlashEvent);\r
+\r
+                               myMp3Player.removeEventListener(JplayerEvent.JPLAYER_SEEKING, jPlayerFlashEvent);\r
+                               myMp3Player.removeEventListener(JplayerEvent.JPLAYER_SEEKED, jPlayerFlashEvent);\r
+                       }\r
+               }\r
+               private function listenToMp4(active:Boolean):void {\r
+                       if(active) {\r
+                               myMp4Player.addEventListener(JplayerEvent.JPLAYER_ERROR, jPlayerFlashEvent);\r
+                               myMp4Player.addEventListener(JplayerEvent.JPLAYER_PROGRESS, jPlayerFlashEvent);\r
+                               myMp4Player.addEventListener(JplayerEvent.JPLAYER_TIMEUPDATE, jPlayerFlashEvent);\r
+                               myMp4Player.addEventListener(JplayerEvent.JPLAYER_ENDED, jPlayerFlashEvent);\r
+\r
+                               myMp4Player.addEventListener(JplayerEvent.JPLAYER_PLAY, jPlayerFlashEvent);\r
+                               myMp4Player.addEventListener(JplayerEvent.JPLAYER_PAUSE, jPlayerFlashEvent);\r
+                               myMp4Player.addEventListener(JplayerEvent.JPLAYER_LOADSTART, jPlayerFlashEvent);\r
+\r
+                               myMp4Player.addEventListener(JplayerEvent.JPLAYER_SEEKING, jPlayerFlashEvent);\r
+                               myMp4Player.addEventListener(JplayerEvent.JPLAYER_SEEKED, jPlayerFlashEvent);\r
+\r
+                               myMp4Player.addEventListener(JplayerEvent.JPLAYER_LOADEDMETADATA, jPlayerMetaDataHandler); // Note the unique handler\r
+                       } else {\r
+                               myMp4Player.removeEventListener(JplayerEvent.JPLAYER_ERROR, jPlayerFlashEvent);\r
+                               myMp4Player.removeEventListener(JplayerEvent.JPLAYER_PROGRESS, jPlayerFlashEvent);\r
+                               myMp4Player.removeEventListener(JplayerEvent.JPLAYER_TIMEUPDATE, jPlayerFlashEvent);\r
+                               myMp4Player.removeEventListener(JplayerEvent.JPLAYER_ENDED, jPlayerFlashEvent);\r
+\r
+                               myMp4Player.removeEventListener(JplayerEvent.JPLAYER_PLAY, jPlayerFlashEvent);\r
+                               myMp4Player.removeEventListener(JplayerEvent.JPLAYER_PAUSE, jPlayerFlashEvent);\r
+                               myMp4Player.removeEventListener(JplayerEvent.JPLAYER_LOADSTART, jPlayerFlashEvent);\r
+\r
+                               myMp4Player.removeEventListener(JplayerEvent.JPLAYER_SEEKING, jPlayerFlashEvent);\r
+                               myMp4Player.removeEventListener(JplayerEvent.JPLAYER_SEEKED, jPlayerFlashEvent);\r
+\r
+                               myMp4Player.removeEventListener(JplayerEvent.JPLAYER_LOADEDMETADATA, jPlayerMetaDataHandler); // Note the unique handler\r
+                       }\r
+               }\r
+               private function fl_setAudio_mp3(src:String):Boolean {\r
+                       if (src != null) {\r
+                               log("fl_setAudio_mp3: "+src);\r
+                               setupListeners(isMp3, true);\r
+                               isMp3 = true;\r
+                               isVideo = false;\r
+                               myMp4Player.clearFile();\r
+                               myMp3Player.setFile(src);\r
+                               return true;\r
+                       } else {\r
+                               log("fl_setAudio_mp3: null");\r
+                               return false;\r
+                       }\r
+               }\r
+               private function fl_setAudio_m4a(src:String):Boolean {\r
+                       if (src != null) {\r
+                               log("fl_setAudio_m4a: "+src);\r
+                               setupListeners(isMp3, false);\r
+                               isMp3 = false;\r
+                               isVideo = false;\r
+                               myMp3Player.clearFile();\r
+                               myMp4Player.setFile(src);\r
+                               return true;\r
+                       } else {\r
+                               log("fl_setAudio_m4a: null");\r
+                               return false;\r
+                       }\r
+               }\r
+               private function fl_setVideo_m4v(src:String):Boolean {\r
+                       if (src != null) {\r
+                               log("fl_setVideo_m4v: "+src);\r
+                               setupListeners(isMp3, false);\r
+                               isMp3 = false;\r
+                               isVideo = true;\r
+                               myMp3Player.clearFile();\r
+                               myMp4Player.setFile(src);\r
+                               return true;\r
+                       } else {\r
+                               log("fl_setVideo_m4v: null");\r
+                               return false;\r
+                       }\r
+               }\r
+               private function fl_clearMedia():void {\r
+                       log("clearMedia.");\r
+                       myMp3Player.clearFile();\r
+                       myMp4Player.clearFile();\r
+               }\r
+               private function fl_load():Boolean {\r
+                       log("load.");\r
+                       if(isMp3) {\r
+                               return myMp3Player.load();\r
+                       } else {\r
+                               return myMp4Player.load();\r
+                       }\r
+               }\r
+               private function fl_play(time:Number = NaN):Boolean {\r
+                       log("play: time = " + time);\r
+                       if(isMp3) {\r
+                               return myMp3Player.play(time * 1000); // Flash uses milliseconds\r
+                       } else {\r
+                               return myMp4Player.play(time * 1000); // Flash uses milliseconds\r
+                       }\r
+               }\r
+               private function fl_pause(time:Number = NaN):Boolean {\r
+                       log("pause: time = " + time);\r
+                       if(isMp3) {\r
+                               return myMp3Player.pause(time * 1000); // Flash uses milliseconds\r
+                       } else {\r
+                               return myMp4Player.pause(time * 1000); // Flash uses milliseconds\r
+                       }\r
+               }\r
+               private function fl_play_head(percent:Number):Boolean {\r
+                       log("play_head: "+percent+"%");\r
+                       if(isMp3) {\r
+                               return myMp3Player.playHead(percent);\r
+                       } else {\r
+                               return myMp4Player.playHead(percent);\r
+                       }\r
+               }\r
+               private function fl_volume(v:Number):void {\r
+                       log("volume: "+v);\r
+                       commonStatus.volume = v;\r
+                       if(!commonStatus.muted) {\r
+                               myMp3Player.setVolume(v);\r
+                               myMp4Player.setVolume(v);\r
+                       }\r
+               }\r
+               private function fl_mute(mute:Boolean):void {\r
+                       log("mute: "+mute);\r
+                       commonStatus.muted = mute;\r
+                       if(mute) {\r
+                               myMp3Player.setVolume(0);\r
+                               myMp4Player.setVolume(0);\r
+                       } else {\r
+                               myMp3Player.setVolume(commonStatus.volume);\r
+                               myMp4Player.setVolume(commonStatus.volume);\r
+                       }\r
+               }\r
+               private function jPlayerFlashEvent(e:JplayerEvent):void {\r
+                       log("jPlayer Flash Event: " + e.type + ": " + e.target);\r
+                       if(ExternalInterface.available) {\r
+                               ExternalInterface.call(jQuery, "jPlayerFlashEvent", e.type, extractStatusData(e.data));\r
+                       }\r
+               }\r
+               private function extractStatusData(data:JplayerStatus):Object {\r
+                       var myStatus:Object = {\r
+                               version: JplayerStatus.VERSION,\r
+                               src: data.src,\r
+                               paused: !data.isPlaying, // Changing this name requires inverting all assignments and conditional statements.\r
+                               srcSet: data.srcSet,\r
+                               seekPercent: data.seekPercent,\r
+                               currentPercentRelative: data.currentPercentRelative,\r
+                               currentPercentAbsolute: data.currentPercentAbsolute,\r
+                               currentTime: data.currentTime / 1000, // JavaScript uses seconds\r
+                               duration: data.duration / 1000, // JavaScript uses seconds\r
+                               volume: commonStatus.volume,\r
+                               muted: commonStatus.muted\r
+                       };\r
+                       log("extractStatusData: sp="+myStatus.seekPercent+" cpr="+myStatus.currentPercentRelative+" cpa="+myStatus.currentPercentAbsolute+" ct="+myStatus.currentTime+" d="+myStatus.duration);\r
+                       return myStatus;\r
+               }\r
+               private function jPlayerMetaDataHandler(e:JplayerEvent):void {\r
+                       log("jPlayerMetaDataHandler:" + e.target);\r
+                       if(ExternalInterface.available) {\r
+                               resizeHandler(new Event(Event.RESIZE));\r
+                               ExternalInterface.call(jQuery, "jPlayerFlashEvent", e.type, extractStatusData(e.data));\r
+                       }\r
+               }\r
+               private function resizeHandler(e:Event):void {\r
+                       log("resizeHandler: stageWidth = " + stage.stageWidth + " | stageHeight = " + stage.stageHeight);\r
+\r
+                       var mediaX:Number = 0;\r
+                       var mediaY:Number = 0;\r
+                       var mediaWidth:Number = 0;\r
+                       var mediaHeight:Number = 0;\r
+\r
+                       if(stage.stageWidth > 0 && stage.stageHeight > 0 && myMp4Player.myVideo.width > 0 && myMp4Player.myVideo.height > 0) {\r
+                               var aspectRatioStage:Number = stage.stageWidth / stage.stageHeight;\r
+                               var aspectRatioVideo:Number = myMp4Player.myVideo.width / myMp4Player.myVideo.height;\r
+                               if(aspectRatioStage < aspectRatioVideo) {\r
+                                       mediaWidth = stage.stageWidth;\r
+                                       mediaHeight = stage.stageWidth / aspectRatioVideo;\r
+                                       mediaX = 0;\r
+                                       mediaY = (stage.stageHeight - mediaHeight) / 2;\r
+                               } else {\r
+                                       mediaWidth = stage.stageHeight * aspectRatioVideo;\r
+                                       mediaHeight = stage.stageHeight;\r
+                                       mediaX = (stage.stageWidth - mediaWidth) / 2;\r
+                                       mediaY = 0;\r
+                               }\r
+                               resizeEntity(myMp4Player, mediaX, mediaY, mediaWidth, mediaHeight);\r
+                       }\r
+                       if(debug && stage.stageWidth > 20 && stage.stageHeight > 20) {\r
+                               txLog.width = stage.stageWidth - 10;\r
+                               txLog.height = stage.stageHeight - 10;\r
+                       }\r
+               }\r
+               private function resizeEntity(entity:Sprite, mediaX:Number, mediaY:Number, mediaWidth:Number, mediaHeight:Number):void {\r
+                       entity.x = mediaX;\r
+                       entity.y = mediaY;\r
+                       entity.width = mediaWidth;\r
+                       entity.height = mediaHeight;\r
+               }\r
+               private function clickHandler(e:MouseEvent):void {\r
+                       if(isMp3) {\r
+                               jPlayerFlashEvent(new JplayerEvent(JplayerEvent.JPLAYER_CLICK, myMp3Player.myStatus, "click"))\r
+                       } else {\r
+                               jPlayerFlashEvent(new JplayerEvent(JplayerEvent.JPLAYER_CLICK, myMp4Player.myStatus, "click"))\r
+                       }\r
+               }\r
+               // This event is never called. See comments in class constructor.\r
+               private function menuSelectHandler_jPlayer(e:ContextMenuEvent):void {\r
+                       navigateToURL(new URLRequest("http://jplayer.org/"), "_blank");\r
+               }\r
+               // This event is never called. See comments in class constructor.\r
+               private function menuSelectHandler_happyworm(e:ContextMenuEvent):void {\r
+                       navigateToURL(new URLRequest("http://happyworm.com/"), "_blank");\r
+               }\r
+               private function log(t:String):void {\r
+                       if(debug) {\r
+                               txLog.text = t + "\n" + txLog.text;\r
+                       }\r
+               }\r
+               private function debugMsgHandler(e:JplayerEvent):void {\r
+                       log(e.msg);\r
+               }\r
+               private function keyboardHandler(e:KeyboardEvent):void {\r
+                       log("keyboardHandler: e.keyCode = " + e.keyCode);\r
+                       switch(e.keyCode) {\r
+                               case 68 : // d\r
+                                       txLog.visible = !txLog.visible;\r
+                                       log("Toggled log display: " + txLog.visible);\r
+                                       break;\r
+                               case 76 : // l\r
+                                       if(e.ctrlKey && e.shiftKey) {\r
+                                               txLog.text = "Cleared log.";\r
+                                       }\r
+                                       break;\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.fla b/apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.fla
new file mode 100644 (file)
index 0000000..61ae40d
Binary files /dev/null and b/apps/media/js/jQuery.jPlayer.2.1.0.source/Jplayer.fla differ
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jplayer.playlist.js b/apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jplayer.playlist.js
new file mode 100644 (file)
index 0000000..0eaa0dd
--- /dev/null
@@ -0,0 +1,452 @@
+/*\r
+ * Playlist Object for the jPlayer Plugin\r
+ * http://www.jplayer.org\r
+ *\r
+ * Copyright (c) 2009 - 2011 Happyworm Ltd\r
+ * Dual licensed under the MIT and GPL licenses.\r
+ *  - http://www.opensource.org/licenses/mit-license.php\r
+ *  - http://www.gnu.org/copyleft/gpl.html\r
+ *\r
+ * Author: Mark J Panaghiston\r
+ * Version: 2.1.0 (jPlayer 2.1.0)\r
+ * Date: 1st September 2011\r
+ */\r
+\r
+/* Code verified using http://www.jshint.com/ */\r
+/*jshint asi:false, bitwise:false, boss:false, browser:true, curly:true, debug:false, eqeqeq:true, eqnull:false, evil:false, forin:false, immed:false, jquery:true, laxbreak:false, newcap:true, noarg:true, noempty:true, nonew:true, nomem:false, onevar:false, passfail:false, plusplus:false, regexp:false, undef:true, sub:false, strict:false, white:false */\r
+/*global  jPlayerPlaylist: true, jQuery:false, alert:false */\r
+\r
+(function($, undefined) {\r
+\r
+       jPlayerPlaylist = function(cssSelector, playlist, options) {\r
+               var self = this;\r
+\r
+               this.current = 0;\r
+               this.loop = false; // Flag used with the jPlayer repeat event\r
+               this.shuffled = false;\r
+               this.removing = false; // Flag is true during remove animation, disabling the remove() method until complete.\r
+\r
+               this.cssSelector = $.extend({}, this._cssSelector, cssSelector); // Object: Containing the css selectors for jPlayer and its cssSelectorAncestor\r
+               this.options = $.extend(true, {}, this._options, options); // Object: The jPlayer constructor options for this playlist and the playlist options\r
+\r
+               this.playlist = []; // Array of Objects: The current playlist displayed (Un-shuffled or Shuffled)\r
+               this.original = []; // Array of Objects: The original playlist\r
+\r
+               this._initPlaylist(playlist); // Copies playlist to this.original. Then mirrors this.original to this.playlist. Creating two arrays, where the element pointers match. (Enables pointer comparison.)\r
+\r
+               // Setup the css selectors for the extra interface items used by the playlist.\r
+               this.cssSelector.title = this.cssSelector.cssSelectorAncestor + " .jp-title"; // Note that the text is written to the decendant li node.\r
+               this.cssSelector.playlist = this.cssSelector.cssSelectorAncestor + " .jp-playlist";\r
+               this.cssSelector.next = this.cssSelector.cssSelectorAncestor + " .jp-next";\r
+               this.cssSelector.previous = this.cssSelector.cssSelectorAncestor + " .jp-previous";\r
+               this.cssSelector.shuffle = this.cssSelector.cssSelectorAncestor + " .jp-shuffle";\r
+               this.cssSelector.shuffleOff = this.cssSelector.cssSelectorAncestor + " .jp-shuffle-off";\r
+\r
+               // Override the cssSelectorAncestor given in options\r
+               this.options.cssSelectorAncestor = this.cssSelector.cssSelectorAncestor;\r
+\r
+               // Override the default repeat event handler\r
+               this.options.repeat = function(event) {\r
+                       self.loop = event.jPlayer.options.loop;\r
+               };\r
+\r
+               // Create a ready event handler to initialize the playlist\r
+               $(this.cssSelector.jPlayer).bind($.jPlayer.event.ready, function(event) {\r
+                       self._init();\r
+               });\r
+\r
+               // Create an ended event handler to move to the next item\r
+               $(this.cssSelector.jPlayer).bind($.jPlayer.event.ended, function(event) {\r
+                       self.next();\r
+               });\r
+\r
+               // Create a play event handler to pause other instances\r
+               $(this.cssSelector.jPlayer).bind($.jPlayer.event.play, function(event) {\r
+                       $(this).jPlayer("pauseOthers");\r
+               });\r
+\r
+               // Create a resize event handler to show the title in full screen mode.\r
+               $(this.cssSelector.jPlayer).bind($.jPlayer.event.resize, function(event) {\r
+                       if(event.jPlayer.options.fullScreen) {\r
+                               $(self.cssSelector.title).show();\r
+                       } else {\r
+                               $(self.cssSelector.title).hide();\r
+                       }\r
+               });\r
+\r
+               // Create click handlers for the extra buttons that do playlist functions.\r
+               $(this.cssSelector.previous).click(function() {\r
+                       self.previous();\r
+                       $(this).blur();\r
+                       return false;\r
+               });\r
+\r
+               $(this.cssSelector.next).click(function() {\r
+                       self.next();\r
+                       $(this).blur();\r
+                       return false;\r
+               });\r
+\r
+               $(this.cssSelector.shuffle).click(function() {\r
+                       self.shuffle(true);\r
+                       return false;\r
+               });\r
+               $(this.cssSelector.shuffleOff).click(function() {\r
+                       self.shuffle(false);\r
+                       return false;\r
+               }).hide();\r
+\r
+               // Put the title in its initial display state\r
+               if(!this.options.fullScreen) {\r
+                       $(this.cssSelector.title).hide();\r
+               }\r
+\r
+               // Remove the empty <li> from the page HTML. Allows page to be valid HTML, while not interfereing with display animations\r
+               $(this.cssSelector.playlist + " ul").empty();\r
+\r
+               // Create .live() handlers for the playlist items along with the free media and remove controls.\r
+               this._createItemHandlers();\r
+\r
+               // Instance jPlayer\r
+               $(this.cssSelector.jPlayer).jPlayer(this.options);\r
+       };\r
+\r
+       jPlayerPlaylist.prototype = {\r
+               _cssSelector: { // static object, instanced in constructor\r
+                       jPlayer: "#jquery_jplayer_1",\r
+                       cssSelectorAncestor: "#jp_container_1"\r
+               },\r
+               _options: { // static object, instanced in constructor\r
+                       playlistOptions: {\r
+                               autoPlay: false,\r
+                               loopOnPrevious: false,\r
+                               shuffleOnLoop: true,\r
+                               enableRemoveControls: false,\r
+                               displayTime: 'slow',\r
+                               addTime: 'fast',\r
+                               removeTime: 'fast',\r
+                               shuffleTime: 'slow',\r
+                               itemClass: "jp-playlist-item",\r
+                               freeGroupClass: "jp-free-media",\r
+                               freeItemClass: "jp-playlist-item-free",\r
+                               removeItemClass: "jp-playlist-item-remove"\r
+                       }\r
+               },\r
+               option: function(option, value) { // For changing playlist options only\r
+                       if(value === undefined) {\r
+                               return this.options.playlistOptions[option];\r
+                       }\r
+\r
+                       this.options.playlistOptions[option] = value;\r
+\r
+                       switch(option) {\r
+                               case "enableRemoveControls":\r
+                                       this._updateControls();\r
+                                       break;\r
+                               case "itemClass":\r
+                               case "freeGroupClass":\r
+                               case "freeItemClass":\r
+                               case "removeItemClass":\r
+                                       this._refresh(true); // Instant\r
+                                       this._createItemHandlers();\r
+                                       break;\r
+                       }\r
+                       return this;\r
+               },\r
+               _init: function() {\r
+                       var self = this;\r
+                       this._refresh(function() {\r
+                               if(self.options.playlistOptions.autoPlay) {\r
+                                       self.play(self.current);\r
+                               } else {\r
+                                       self.select(self.current);\r
+                               }\r
+                       });\r
+               },\r
+               _initPlaylist: function(playlist) {\r
+                       this.current = 0;\r
+                       this.shuffled = false;\r
+                       this.removing = false;\r
+                       this.original = $.extend(true, [], playlist); // Copy the Array of Objects\r
+                       this._originalPlaylist();\r
+               },\r
+               _originalPlaylist: function() {\r
+                       var self = this;\r
+                       this.playlist = [];\r
+                       // Make both arrays point to the same object elements. Gives us 2 different arrays, each pointing to the same actual object. ie., Not copies of the object.\r
+                       $.each(this.original, function(i,v) {\r
+                               self.playlist[i] = self.original[i];\r
+                       });\r
+               },\r
+               _refresh: function(instant) {\r
+                       /* instant: Can be undefined, true or a function.\r
+                        *      undefined -> use animation timings\r
+                        *      true -> no animation\r
+                        *      function -> use animation timings and excute function at half way point.\r
+                        */\r
+                       var self = this;\r
+\r
+                       if(instant && !$.isFunction(instant)) {\r
+                               $(this.cssSelector.playlist + " ul").empty();\r
+                               $.each(this.playlist, function(i,v) {\r
+                                       $(self.cssSelector.playlist + " ul").append(self._createListItem(self.playlist[i]));\r
+                               });\r
+                               this._updateControls();\r
+                       } else {\r
+                               var displayTime = $(this.cssSelector.playlist + " ul").children().length ? this.options.playlistOptions.displayTime : 0;\r
+\r
+                               $(this.cssSelector.playlist + " ul").slideUp(displayTime, function() {\r
+                                       var $this = $(this);\r
+                                       $(this).empty();\r
+                                       \r
+                                       $.each(self.playlist, function(i,v) {\r
+                                               $this.append(self._createListItem(self.playlist[i]));\r
+                                       });\r
+                                       self._updateControls();\r
+                                       if($.isFunction(instant)) {\r
+                                               instant();\r
+                                       }\r
+                                       if(self.playlist.length) {\r
+                                               $(this).slideDown(self.options.playlistOptions.displayTime);\r
+                                       } else {\r
+                                               $(this).show();\r
+                                       }\r
+                               });\r
+                       }\r
+               },\r
+               _createListItem: function(media) {\r
+                       var self = this;\r
+\r
+                       // Wrap the <li> contents in a <div>\r
+                       var listItem = "<li><div>";\r
+\r
+                       // Create remove control\r
+                       listItem += "<a href='javascript:;' class='" + this.options.playlistOptions.removeItemClass + "'>&times;</a>";\r
+\r
+                       // Create links to free media\r
+                       if(media.free) {\r
+                               var first = true;\r
+                               listItem += "<span class='" + this.options.playlistOptions.freeGroupClass + "'>(";\r
+                               $.each(media, function(property,value) {\r
+                                       if($.jPlayer.prototype.format[property]) { // Check property is a media format.\r
+                                               if(first) {\r
+                                                       first = false;\r
+                                               } else {\r
+                                                       listItem += " | ";\r
+                                               }\r
+                                               listItem += "<a class='" + self.options.playlistOptions.freeItemClass + "' href='" + value + "' tabindex='1'>" + property + "</a>";\r
+                                       }\r
+                               });\r
+                               listItem += ")</span>";\r
+                       }\r
+\r
+                       // The title is given next in the HTML otherwise the float:right on the free media corrupts in IE6/7\r
+                       listItem += "<a href='javascript:;' class='" + this.options.playlistOptions.itemClass + "' tabindex='1'>" + media.title + (media.artist ? " <span class='jp-artist'>by " + media.artist + "</span>" : "") + "</a>";\r
+                       listItem += "</div></li>";\r
+\r
+                       return listItem;\r
+               },\r
+               _createItemHandlers: function() {\r
+                       var self = this;\r
+                       // Create .live() handlers for the playlist items\r
+                       $(this.cssSelector.playlist + " a." + this.options.playlistOptions.itemClass).die("click").live("click", function() {\r
+                               var index = $(this).parent().parent().index();\r
+                               if(self.current !== index) {\r
+                                       self.play(index);\r
+                               } else {\r
+                                       $(self.cssSelector.jPlayer).jPlayer("play");\r
+                               }\r
+                               $(this).blur();\r
+                               return false;\r
+                       });\r
+\r
+                       // Create .live() handlers that disable free media links to force access via right click\r
+                       $(self.cssSelector.playlist + " a." + this.options.playlistOptions.freeItemClass).die("click").live("click", function() {\r
+                               $(this).parent().parent().find("." + self.options.playlistOptions.itemClass).click();\r
+                               $(this).blur();\r
+                               return false;\r
+                       });\r
+\r
+                       // Create .live() handlers for the remove controls\r
+                       $(self.cssSelector.playlist + " a." + this.options.playlistOptions.removeItemClass).die("click").live("click", function() {\r
+                               var index = $(this).parent().parent().index();\r
+                               self.remove(index);\r
+                               $(this).blur();\r
+                               return false;\r
+                       });\r
+               },\r
+               _updateControls: function() {\r
+                       if(this.options.playlistOptions.enableRemoveControls) {\r
+                               $(this.cssSelector.playlist + " ." + this.options.playlistOptions.removeItemClass).show();\r
+                       } else {\r
+                               $(this.cssSelector.playlist + " ." + this.options.playlistOptions.removeItemClass).hide();\r
+                       }\r
+                       if(this.shuffled) {\r
+                               $(this.cssSelector.shuffleOff).show();\r
+                               $(this.cssSelector.shuffle).hide();\r
+                       } else {\r
+                               $(this.cssSelector.shuffleOff).hide();\r
+                               $(this.cssSelector.shuffle).show();\r
+                       }\r
+               },\r
+               _highlight: function(index) {\r
+                       if(this.playlist.length && index !== undefined) {\r
+                               $(this.cssSelector.playlist + " .jp-playlist-current").removeClass("jp-playlist-current");\r
+                               $(this.cssSelector.playlist + " li:nth-child(" + (index + 1) + ")").addClass("jp-playlist-current").find(".jp-playlist-item").addClass("jp-playlist-current");\r
+                               $(this.cssSelector.title + " li").html(this.playlist[index].title + (this.playlist[index].artist ? " <span class='jp-artist'>by " + this.playlist[index].artist + "</span>" : ""));\r
+                       }\r
+               },\r
+               setPlaylist: function(playlist) {\r
+                       this._initPlaylist(playlist);\r
+                       this._init();\r
+               },\r
+               add: function(media, playNow) {\r
+                       $(this.cssSelector.playlist + " ul").append(this._createListItem(media)).find("li:last-child").hide().slideDown(this.options.playlistOptions.addTime);\r
+                       this._updateControls();\r
+                       this.original.push(media);\r
+                       this.playlist.push(media); // Both array elements share the same object pointer. Comforms with _initPlaylist(p) system.\r
+\r
+                       if(playNow) {\r
+                               this.play(this.playlist.length - 1);\r
+                       } else {\r
+                               if(this.original.length === 1) {\r
+                                       this.select(0);\r
+                               }\r
+                       }\r
+               },\r
+               remove: function(index) {\r
+                       var self = this;\r
+\r
+                       if(index === undefined) {\r
+                               this._initPlaylist([]);\r
+                               this._refresh(function() {\r
+                                       $(self.cssSelector.jPlayer).jPlayer("clearMedia");\r
+                               });\r
+                               return true;\r
+                       } else {\r
+\r
+                               if(this.removing) {\r
+                                       return false;\r
+                               } else {\r
+                                       index = (index < 0) ? self.original.length + index : index; // Negative index relates to end of array.\r
+                                       if(0 <= index && index < this.playlist.length) {\r
+                                               this.removing = true;\r
+\r
+                                               $(this.cssSelector.playlist + " li:nth-child(" + (index + 1) + ")").slideUp(this.options.playlistOptions.removeTime, function() {\r
+                                                       $(this).remove();\r
+\r
+                                                       if(self.shuffled) {\r
+                                                               var item = self.playlist[index];\r
+                                                               $.each(self.original, function(i,v) {\r
+                                                                       if(self.original[i] === item) {\r
+                                                                               self.original.splice(i, 1);\r
+                                                                               return false; // Exit $.each\r
+                                                                       }\r
+                                                               });\r
+                                                               self.playlist.splice(index, 1);\r
+                                                       } else {\r
+                                                               self.original.splice(index, 1);\r
+                                                               self.playlist.splice(index, 1);\r
+                                                       }\r
+\r
+                                                       if(self.original.length) {\r
+                                                               if(index === self.current) {\r
+                                                                       self.current = (index < self.original.length) ? self.current : self.original.length - 1; // To cope when last element being selected when it was removed\r
+                                                                       self.select(self.current);\r
+                                                               } else if(index < self.current) {\r
+                                                                       self.current--;\r
+                                                               }\r
+                                                       } else {\r
+                                                               $(self.cssSelector.jPlayer).jPlayer("clearMedia");\r
+                                                               self.current = 0;\r
+                                                               self.shuffled = false;\r
+                                                               self._updateControls();\r
+                                                       }\r
+\r
+                                                       self.removing = false;\r
+                                               });\r
+                                       }\r
+                                       return true;\r
+                               }\r
+                       }\r
+               },\r
+               select: function(index) {\r
+                       index = (index < 0) ? this.original.length + index : index; // Negative index relates to end of array.\r
+                       if(0 <= index && index < this.playlist.length) {\r
+                               this.current = index;\r
+                               this._highlight(index);\r
+                               $(this.cssSelector.jPlayer).jPlayer("setMedia", this.playlist[this.current]);\r
+                       } else {\r
+                               this.current = 0;\r
+                       }\r
+               },\r
+               play: function(index) {\r
+                       index = (index < 0) ? this.original.length + index : index; // Negative index relates to end of array.\r
+                       if(0 <= index && index < this.playlist.length) {\r
+                               if(this.playlist.length) {\r
+                                       this.select(index);\r
+                                       $(this.cssSelector.jPlayer).jPlayer("play");\r
+                               }\r
+                       } else if(index === undefined) {\r
+                               $(this.cssSelector.jPlayer).jPlayer("play");\r
+                       }\r
+               },\r
+               pause: function() {\r
+                       $(this.cssSelector.jPlayer).jPlayer("pause");\r
+               },\r
+               next: function() {\r
+                       var index = (this.current + 1 < this.playlist.length) ? this.current + 1 : 0;\r
+\r
+                       if(this.loop) {\r
+                               // See if we need to shuffle before looping to start, and only shuffle if more than 1 item.\r
+                               if(index === 0 && this.shuffled && this.options.playlistOptions.shuffleOnLoop && this.playlist.length > 1) {\r
+                                       this.shuffle(true, true); // playNow\r
+                               } else {\r
+                                       this.play(index);\r
+                               }\r
+                       } else {\r
+                               // The index will be zero if it just looped round\r
+                               if(index > 0) {\r
+                                       this.play(index);\r
+                               }\r
+                       }\r
+               },\r
+               previous: function() {\r
+                       var index = (this.current - 1 >= 0) ? this.current - 1 : this.playlist.length - 1;\r
+\r
+                       if(this.loop && this.options.playlistOptions.loopOnPrevious || index < this.playlist.length - 1) {\r
+                               this.play(index);\r
+                       }\r
+               },\r
+               shuffle: function(shuffled, playNow) {\r
+                       var self = this;\r
+\r
+                       if(shuffled === undefined) {\r
+                               shuffled = !this.shuffled;\r
+                       }\r
+\r
+                       if(shuffled || shuffled !== this.shuffled) {\r
+\r
+                               $(this.cssSelector.playlist + " ul").slideUp(this.options.playlistOptions.shuffleTime, function() {\r
+                                       self.shuffled = shuffled;\r
+                                       if(shuffled) {\r
+                                               self.playlist.sort(function() {\r
+                                                       return 0.5 - Math.random();\r
+                                               });\r
+                                       } else {\r
+                                               self._originalPlaylist();\r
+                                       }\r
+                                       self._refresh(true); // Instant\r
+\r
+                                       if(playNow || !$(self.cssSelector.jPlayer).data("jPlayer").status.paused) {\r
+                                               self.play(0);\r
+                                       } else {\r
+                                               self.select(0);\r
+                                       }\r
+\r
+                                       $(this).slideDown(self.options.playlistOptions.shuffleTime);\r
+                               });\r
+                       }\r
+               }\r
+       };\r
+})(jQuery);\r
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jquery.jplayer.inspector.js b/apps/media/js/jQuery.jPlayer.2.1.0.source/add-on/jquery.jplayer.inspector.js
new file mode 100644 (file)
index 0000000..46c090a
--- /dev/null
@@ -0,0 +1,331 @@
+/*\r
+ * jPlayerInspector Plugin for jPlayer (2.0.0+) Plugin for jQuery JavaScript Library\r
+ * http://www.happyworm.com/jquery/jplayer\r
+ *\r
+ * Copyright (c) 2009 - 2011 Happyworm Ltd\r
+ * Dual licensed under the MIT and GPL licenses.\r
+ *  - http://www.opensource.org/licenses/mit-license.php\r
+ *  - http://www.gnu.org/copyleft/gpl.html\r
+ *\r
+ * Author: Mark J Panaghiston\r
+ * Version: 1.0.3\r
+ * Date: 7th August 2011\r
+ *\r
+ * For use with jPlayer Version: 2.0.29\r
+ *\r
+ * Note: Declare inspector instances after jPlayer instances. ie., Otherwise the jPlayer instance is nonsense.\r
+ */\r
+\r
+(function($, undefined) {\r
+       $.jPlayerInspector = {};\r
+       $.jPlayerInspector.i = 0;\r
+       $.jPlayerInspector.defaults = {\r
+               jPlayer: undefined, // The jQuery selector of the jPlayer instance to inspect.\r
+               idPrefix: "jplayer_inspector_",\r
+               visible: false\r
+       };\r
+       \r
+       var methods = {\r
+               init: function(options) {\r
+                       var self = this;\r
+                       var $this = $(this);\r
+                       \r
+                       var config = $.extend({}, $.jPlayerInspector.defaults, options);\r
+                       $(this).data("jPlayerInspector", config);\r
+\r
+                       config.id = $(this).attr("id");\r
+                       config.jPlayerId = config.jPlayer.attr("id");\r
+\r
+                       config.windowId = config.idPrefix + "window_" + $.jPlayerInspector.i;\r
+                       config.statusId = config.idPrefix + "status_" + $.jPlayerInspector.i;\r
+                       config.configId = config.idPrefix + "config_" + $.jPlayerInspector.i;\r
+                       config.toggleId = config.idPrefix + "toggle_" + $.jPlayerInspector.i;\r
+                       config.eventResetId = config.idPrefix + "event_reset_" + $.jPlayerInspector.i;\r
+                       config.updateId = config.idPrefix + "update_" + $.jPlayerInspector.i;\r
+                       config.eventWindowId = config.idPrefix + "event_window_" + $.jPlayerInspector.i;\r
+                       \r
+                       config.eventId = {};\r
+                       config.eventJq = {};\r
+                       config.eventTimeout = {};\r
+                       config.eventOccurrence = {};\r
+                       \r
+                       $.each($.jPlayer.event, function(eventName,eventType) {\r
+                               config.eventId[eventType] = config.idPrefix + "event_" + eventName + "_" + $.jPlayerInspector.i;\r
+                               config.eventOccurrence[eventType] = 0;\r
+                       });\r
+                       \r
+                       var structure = \r
+                               '<p><a href="#" id="' + config.toggleId + '">' + (config.visible ? "Hide" : "Show") + '</a> jPlayer Inspector</p>' \r
+                               + '<div id="' + config.windowId + '">'\r
+                                       + '<div id="' + config.statusId + '"></div>'\r
+                                       + '<div id="' + config.eventWindowId + '" style="padding:5px 5px 0 5px;background-color:#eee;border:1px dotted #000;">'\r
+                                               + '<p style="margin:0 0 10px 0;"><strong>jPlayer events that have occurred over the past 1 second:</strong>'\r
+                                               + '<br />(Backgrounds: <span style="padding:0 5px;background-color:#eee;border:1px dotted #000;">Never occurred</span> <span style="padding:0 5px;background-color:#fff;border:1px dotted #000;">Occurred before</span> <span style="padding:0 5px;background-color:#9f9;border:1px dotted #000;">Occurred</span> <span style="padding:0 5px;background-color:#ff9;border:1px dotted #000;">Multiple occurrences</span> <a href="#" id="' + config.eventResetId + '">reset</a>)</p>';\r
+                       \r
+                       // MJP: Would use the next 3 lines for ease, but the events are just slapped on the page.\r
+                       // $.each($.jPlayer.event, function(eventName,eventType) {\r
+                       //      structure += '<div id="' + config.eventId[eventType] + '" style="float:left;">' + eventName + '</div>';\r
+                       // });\r
+                       \r
+                       var eventStyle = "float:left;margin:0 5px 5px 0;padding:0 5px;border:1px dotted #000;";\r
+                       // MJP: Doing it longhand so order and layout easier to control.\r
+                       structure +=\r
+                                               '<div id="' + config.eventId[$.jPlayer.event.ready] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.flashreset] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.resize] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.repeat] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.click] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.error] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.warning] + '" style="' + eventStyle + '"></div>'\r
+\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.loadstart] + '" style="clear:left;' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.progress] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.timeupdate] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.volumechange] + '" style="' + eventStyle + '"></div>'\r
+\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.play] + '" style="clear:left;' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.pause] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.waiting] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.playing] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.seeking] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.seeked] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.ended] + '" style="' + eventStyle + '"></div>'\r
+\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.loadeddata] + '" style="clear:left;' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.loadedmetadata] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.canplay] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.canplaythrough] + '" style="' + eventStyle + '"></div>'\r
+\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.suspend] + '" style="clear:left;' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.abort] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.emptied] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.stalled] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.ratechange] + '" style="' + eventStyle + '"></div>'\r
+                                               + '<div id="' + config.eventId[$.jPlayer.event.durationchange] + '" style="' + eventStyle + '"></div>'\r
+\r
+                                               + '<div style="clear:both"></div>';\r
+\r
+                       // MJP: Would like a check here in case we missed an event.\r
+\r
+                       // MJP: Check fails, since it is not on the page yet.\r
+/*                     $.each($.jPlayer.event, function(eventName,eventType) {\r
+                               if($("#" + config.eventId[eventType])[0] === undefined) {\r
+                                       structure += '<div id="' + config.eventId[eventType] + '" style="clear:left;' + eventStyle + '">' + eventName + '</div>';\r
+                               }\r
+                       });\r
+*/\r
+                       structure +=\r
+                                       '</div>'\r
+                                       + '<p><a href="#" id="' + config.updateId + '">Update</a> jPlayer Inspector</p>'\r
+                                       + '<div id="' + config.configId + '"></div>'\r
+                               + '</div>';\r
+                       $(this).html(structure);\r
+                       \r
+                       config.windowJq = $("#" + config.windowId);\r
+                       config.statusJq = $("#" + config.statusId);\r
+                       config.configJq = $("#" + config.configId);\r
+                       config.toggleJq = $("#" + config.toggleId);\r
+                       config.eventResetJq = $("#" + config.eventResetId);\r
+                       config.updateJq = $("#" + config.updateId);\r
+\r
+                       $.each($.jPlayer.event, function(eventName,eventType) {\r
+                               config.eventJq[eventType] = $("#" + config.eventId[eventType]);\r
+                               config.eventJq[eventType].text(eventName + " (" + config.eventOccurrence[eventType] + ")"); // Sets the text to the event name and (0);\r
+                               \r
+                               config.jPlayer.bind(eventType + ".jPlayerInspector", function(e) {\r
+                                       config.eventOccurrence[e.type]++;\r
+                                       if(config.eventOccurrence[e.type] > 1) {\r
+                                               config.eventJq[e.type].css("background-color","#ff9");\r
+                                       } else {\r
+                                               config.eventJq[e.type].css("background-color","#9f9");\r
+                                       }\r
+                                       config.eventJq[e.type].text(eventName + " (" + config.eventOccurrence[e.type] + ")");\r
+                                       // The timer to handle the color\r
+                                       clearTimeout(config.eventTimeout[e.type]);\r
+                                       config.eventTimeout[e.type] = setTimeout(function() {\r
+                                               config.eventJq[e.type].css("background-color","#fff");\r
+                                       }, 1000);\r
+                                       // The timer to handle the occurences.\r
+                                       setTimeout(function() {\r
+                                               config.eventOccurrence[e.type]--;\r
+                                               config.eventJq[e.type].text(eventName + " (" + config.eventOccurrence[e.type] + ")");\r
+                                       }, 1000);\r
+                                       if(config.visible) { // Update the status, if inspector open.\r
+                                               $this.jPlayerInspector("updateStatus");\r
+                                       }\r
+                               });\r
+                       });\r
+\r
+                       config.jPlayer.bind($.jPlayer.event.ready + ".jPlayerInspector", function(e) {\r
+                               $this.jPlayerInspector("updateConfig");\r
+                       });\r
+\r
+                       config.toggleJq.click(function() {\r
+                               if(config.visible) {\r
+                                       $(this).text("Show");\r
+                                       config.windowJq.hide();\r
+                                       config.statusJq.empty();\r
+                                       config.configJq.empty();\r
+                               } else {\r
+                                       $(this).text("Hide");\r
+                                       config.windowJq.show();\r
+                                       config.updateJq.click();\r
+                               }\r
+                               config.visible = !config.visible;\r
+                               $(this).blur();\r
+                               return false;\r
+                       });\r
+\r
+                       config.eventResetJq.click(function() {\r
+                               $.each($.jPlayer.event, function(eventName,eventType) {\r
+                                       config.eventJq[eventType].css("background-color","#eee");\r
+                               });\r
+                               $(this).blur();\r
+                               return false;\r
+                       });\r
+\r
+                       config.updateJq.click(function() {\r
+                               $this.jPlayerInspector("updateStatus");\r
+                               $this.jPlayerInspector("updateConfig");\r
+                               return false;\r
+                       });\r
+\r
+                       if(!config.visible) {\r
+                               config.windowJq.hide();\r
+                       } else {\r
+                               // config.updateJq.click();\r
+                       }\r
+                       \r
+                       $.jPlayerInspector.i++;\r
+\r
+                       return this;\r
+               },\r
+               destroy: function() {\r
+                       $(this).data("jPlayerInspector") && $(this).data("jPlayerInspector").jPlayer.unbind(".jPlayerInspector");\r
+                       $(this).empty();\r
+               },\r
+               updateConfig: function() { // This displays information about jPlayer's configuration in inspector\r
+               \r
+                       var jPlayerInfo = "<p>This jPlayer instance is running in your browser where:<br />"\r
+\r
+                       for(i = 0; i < $(this).data("jPlayerInspector").jPlayer.data("jPlayer").solutions.length; i++) {\r
+                               var solution = $(this).data("jPlayerInspector").jPlayer.data("jPlayer").solutions[i];\r
+                               jPlayerInfo += "&nbsp;jPlayer's <strong>" + solution + "</strong> solution is";                         \r
+                               if($(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].used) {\r
+                                       jPlayerInfo += " being <strong>used</strong> and will support:<strong>";\r
+                                       for(format in $(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].support) {\r
+                                               if($(this).data("jPlayerInspector").jPlayer.data("jPlayer")[solution].support[format]) {\r
+                                                       jPlayerInfo += " " + format;\r
+                                               }\r
+                                       }\r
+                                       jPlayerInfo += "</strong><br />";\r
+                               } else {\r
+                                       jPlayerInfo += " <strong>not required</strong><br />";\r
+                               }\r
+                       }\r
+                       jPlayerInfo += "</p>";\r
+\r
+                       if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.active) {\r
+                               if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").flash.active) {\r
+                                       jPlayerInfo += "<strong>Problem with jPlayer since both HTML5 and Flash are active.</strong>";\r
+                               } else {\r
+                                       jPlayerInfo += "The <strong>HTML5 is active</strong>.";\r
+                               }\r
+                       } else {\r
+                               if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").flash.active) {\r
+                                       jPlayerInfo += "The <strong>Flash is active</strong>.";\r
+                               } else {\r
+                                       jPlayerInfo += "No solution is currently active. jPlayer needs a setMedia().";\r
+                               }\r
+                       }\r
+                       jPlayerInfo += "</p>";\r
+\r
+                       var formatType = $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.formatType;\r
+                       jPlayerInfo += "<p><code>status.formatType = '" + formatType + "'</code><br />";\r
+                       if(formatType) {\r
+                               jPlayerInfo += "<code>Browser canPlay('" + $.jPlayer.prototype.format[formatType].codec + "')</code>";\r
+                       } else {\r
+                               jPlayerInfo += "</p>";\r
+                       }\r
+                       \r
+                       jPlayerInfo += "<p><code>status.src = '" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.src + "'</code></p>";\r
+\r
+                       jPlayerInfo += "<p><code>status.media = {<br />";\r
+                       for(prop in $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.media) {\r
+                               jPlayerInfo += "&nbsp;" + prop + ": " + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.media[prop] + "<br />"; // Some are strings\r
+                       }\r
+                       jPlayerInfo += "};</code></p>"\r
+\r
+                       + "<p>Raw browser test for HTML5 support. Should equal a function if HTML5 is available.<br />";\r
+                       if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.audio.available) {\r
+                               jPlayerInfo += "<code>htmlElement.audio.canPlayType = " + (typeof $(this).data("jPlayerInspector").jPlayer.data("jPlayer").htmlElement.audio.canPlayType) +"</code><br />"\r
+                       }\r
+                       if($(this).data("jPlayerInspector").jPlayer.data("jPlayer").html.video.available) {\r
+                               jPlayerInfo += "<code>htmlElement.video.canPlayType = " + (typeof $(this).data("jPlayerInspector").jPlayer.data("jPlayer").htmlElement.video.canPlayType) +"</code>";\r
+                       }\r
+                       jPlayerInfo += "</p>";\r
+\r
+                       jPlayerInfo += "<p>This instance is using the constructor options:<br />"\r
+                       + "<code>$('#" + $(this).data("jPlayerInspector").jPlayer.data("jPlayer").internal.self.id + "').jPlayer({<br />"\r
+\r
+                       + "&nbsp;swfPath: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "swfPath") + "',<br />"\r
+\r
+                       + "&nbsp;solution: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "solution") + "',<br />"\r
+\r
+                       + "&nbsp;supplied: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "supplied") + "',<br />"\r
+\r
+                       + "&nbsp;preload: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "preload") + "',<br />"\r
+                       \r
+                       + "&nbsp;volume: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "volume") + ",<br />"\r
+                       \r
+                       + "&nbsp;muted: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "muted") + ",<br />"\r
+\r
+                       + "&nbsp;backgroundColor: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "backgroundColor") + "',<br />"\r
+\r
+                       + "&nbsp;cssSelectorAncestor: '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelectorAncestor") + "',<br />"\r
+\r
+                       + "&nbsp;cssSelector: {";\r
+\r
+                       var cssSelector = $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector");\r
+                       for(prop in cssSelector) {\r
+                               \r
+                               // jPlayerInfo += "<br />&nbsp;&nbsp;" + prop + ": '" + cssSelector[prop] + "'," // This works too of course, but want to use option method for deep keys.\r
+                               jPlayerInfo += "<br />&nbsp;&nbsp;" + prop + ": '" + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector." + prop) + "',"\r
+                       }\r
+\r
+                       jPlayerInfo = jPlayerInfo.slice(0, -1); // Because the sloppy comma was bugging me.\r
+\r
+                       jPlayerInfo += "<br />&nbsp;},<br />"\r
+\r
+                       + "&nbsp;errorAlerts: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "errorAlerts") + ",<br />"\r
+                       \r
+                       + "&nbsp;warningAlerts: " + $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "warningAlerts") + "<br />"\r
+\r
+                       + "});</code></p>";\r
+                       $(this).data("jPlayerInspector").configJq.html(jPlayerInfo);\r
+                       return this;\r
+               },\r
+               updateStatus: function() { // This displays information about jPlayer's status in the inspector\r
+                       $(this).data("jPlayerInspector").statusJq.html(\r
+                               "<p>jPlayer is " +\r
+                               ($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.paused ? "paused" : "playing") +\r
+                               " at time: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentTime*10)/10 + "s." +\r
+                               " (d: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.duration*10)/10 + "s" +\r
+                               ", sp: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.seekPercent) + "%" +\r
+                               ", cpr: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentPercentRelative) + "%" +\r
+                               ", cpa: " + Math.floor($(this).data("jPlayerInspector").jPlayer.data("jPlayer").status.currentPercentAbsolute) + "%)</p>"\r
+                       );\r
+                       return this;\r
+               }\r
+       };\r
+       $.fn.jPlayerInspector = function( method ) {\r
+               // Method calling logic\r
+               if ( methods[method] ) {\r
+                       return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));\r
+               } else if ( typeof method === 'object' || ! method ) {\r
+                       return methods.init.apply( this, arguments );\r
+               } else {\r
+                       $.error( 'Method ' +  method + ' does not exist on jQuery.jPlayerInspector' );\r
+               }    \r
+       };\r
+})(jQuery);\r
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerEvent.as b/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerEvent.as
new file mode 100644 (file)
index 0000000..addb97a
--- /dev/null
@@ -0,0 +1,69 @@
+/*\r
+ * jPlayer Plugin for jQuery JavaScript Library\r
+ * http://www.happyworm.com/jquery/jplayer\r
+ *\r
+ * Copyright (c) 2009 - 2011 Happyworm Ltd\r
+ * Dual licensed under the MIT and GPL licenses.\r
+ *  - http://www.opensource.org/licenses/mit-license.php\r
+ *  - http://www.gnu.org/copyleft/gpl.html\r
+ *\r
+ * Author: Mark J Panaghiston\r
+ * Date: 8th August 2011\r
+ */\r
+\r
+package happyworm.jPlayer {\r
+       import flash.events.Event;\r
+       \r
+       public class JplayerEvent extends Event {\r
+               \r
+               // The event strings must match those in the JavaScript's $.jPlayer.event object\r
+\r
+               public static const JPLAYER_READY:String = "jPlayer_ready";\r
+               public static const JPLAYER_FLASHRESET:String = "jPlayer_flashreset"; // Handled in JavaScript\r
+               public static const JPLAYER_RESIZE:String = "jPlayer_resize"; // Handled in JavaScript\r
+               public static const JPLAYER_REPEAT:String = "jPlayer_repeat"; // Handled in JavaScript\r
+               public static const JPLAYER_CLICK:String = "jPlayer_click";\r
+               public static const JPLAYER_ERROR:String = "jPlayer_error";\r
+               public static const JPLAYER_WARNING:String = "jPlayer_warning"; // Currently not used by the flash solution\r
+\r
+               public static const JPLAYER_LOADSTART:String = "jPlayer_loadstart";\r
+               public static const JPLAYER_PROGRESS:String = "jPlayer_progress";\r
+               public static const JPLAYER_SUSPEND:String = "jPlayer_suspend"; // Not implemented\r
+               public static const JPLAYER_ABORT:String = "jPlayer_abort"; // Not implemented\r
+               public static const JPLAYER_EMPTIED:String = "jPlayer_emptied"; // Not implemented\r
+               public static const JPLAYER_STALLED:String = "jPlayer_stalled"; // Not implemented\r
+               public static const JPLAYER_PLAY:String = "jPlayer_play";\r
+               public static const JPLAYER_PAUSE:String = "jPlayer_pause";\r
+               public static const JPLAYER_LOADEDMETADATA:String = "jPlayer_loadedmetadata"; // MP3 has no equivilent\r
+               public static const JPLAYER_LOADEDDATA:String = "jPlayer_loadeddata"; // Not implemented\r
+               public static const JPLAYER_WAITING:String = "jPlayer_waiting"; // Not implemented\r
+               public static const JPLAYER_PLAYING:String = "jPlayer_playing"; // Not implemented\r
+               public static const JPLAYER_CANPLAY:String = "jPlayer_canplay"; // Not implemented\r
+               public static const JPLAYER_CANPLAYTHROUGH:String = "jPlayer_canplaythrough"; // Not implemented\r
+               public static const JPLAYER_SEEKING:String = "jPlayer_seeking";\r
+               public static const JPLAYER_SEEKED:String = "jPlayer_seeked";\r
+               public static const JPLAYER_TIMEUPDATE:String = "jPlayer_timeupdate";\r
+               public static const JPLAYER_ENDED:String = "jPlayer_ended";\r
+               public static const JPLAYER_RATECHANGE:String = "jPlayer_ratechange"; // Not implemented\r
+               public static const JPLAYER_DURATIONCHANGE:String = "jPlayer_durationchange"; // Not implemented\r
+               public static const JPLAYER_VOLUMECHANGE:String = "jPlayer_volumechange"; // See JavaScript\r
+\r
+               // Events used internal to jPlayer's Flash.\r
+               public static const DEBUG_MSG:String = "debug_msg";\r
+\r
+               public var data:JplayerStatus;\r
+               public var msg:String = ""\r
+\r
+               public function JplayerEvent(type:String, data:JplayerStatus, msg:String = "", bubbles:Boolean = false, cancelable:Boolean = false) {\r
+                       super(type, bubbles, cancelable);\r
+                       this.data = data;\r
+                       this.msg = msg;\r
+               }\r
+               public override function clone():Event {\r
+                       return new JplayerEvent(type, data, msg, bubbles, cancelable);\r
+               }\r
+               public override function toString():String {\r
+                       return formatToString("JplayerEvent", "type", "bubbles", "cancelable", "eventPhase", "data", "msg");\r
+               }\r
+       }\r
+}
\ No newline at end of file
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp3.as b/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp3.as
new file mode 100644 (file)
index 0000000..8c51d5b
--- /dev/null
@@ -0,0 +1,328 @@
+/*\r
+ * jPlayer Plugin for jQuery JavaScript Library\r
+ * http://www.happyworm.com/jquery/jplayer\r
+ *\r
+ * Copyright (c) 2009 - 2011 Happyworm Ltd\r
+ * Dual licensed under the MIT and GPL licenses.\r
+ *  - http://www.opensource.org/licenses/mit-license.php\r
+ *  - http://www.gnu.org/copyleft/gpl.html\r
+ *\r
+ * Author: Mark J Panaghiston\r
+ * Date: 1st September 2011\r
+ */\r
+\r
+package happyworm.jPlayer {\r
+       import flash.display.Sprite;\r
+\r
+       import flash.media.Sound;\r
+       import flash.media.SoundChannel;\r
+       import flash.media.SoundLoaderContext;\r
+       import flash.media.SoundTransform;\r
+       import flash.net.URLRequest;\r
+       import flash.utils.Timer;\r
+       import flash.errors.IOError;\r
+       import flash.events.*;\r
+\r
+       public class JplayerMp3 extends Sprite {\r
+               private var mySound:Sound = new Sound();\r
+               private var myChannel:SoundChannel = new SoundChannel();\r
+               private var myContext:SoundLoaderContext = new SoundLoaderContext(3000, false);\r
+               private var myTransform:SoundTransform = new SoundTransform();\r
+               private var myRequest:URLRequest = new URLRequest();\r
+\r
+               private var timeUpdateTimer:Timer = new Timer(250, 0); // Matched to HTML event freq\r
+               private var progressTimer:Timer = new Timer(250, 0); // Matched to HTML event freq\r
+               private var seekingTimer:Timer = new Timer(100, 0); // Internal: How often seeking is checked to see if it is over.\r
+               \r
+               public var myStatus:JplayerStatus = new JplayerStatus();\r
+\r
+               public function JplayerMp3(volume:Number) {\r
+                       timeUpdateTimer.addEventListener(TimerEvent.TIMER, timeUpdateHandler);\r
+                       progressTimer.addEventListener(TimerEvent.TIMER, progressHandler);\r
+                       seekingTimer.addEventListener(TimerEvent.TIMER, seekingHandler);\r
+                       setVolume(volume);\r
+               }\r
+               public function setFile(src:String):void {\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "setFile: " + src));\r
+                       if(myStatus.isPlaying) {\r
+                               myChannel.stop();\r
+                               progressUpdates(false);\r
+                               timeUpdates(false);\r
+                       }\r
+                       try {\r
+                               mySound.close();\r
+                       } catch (err:IOError) {\r
+                               // Occurs if the file is either yet to be opened or has finished downloading.\r
+                       }\r
+                       mySound = null;\r
+                       mySound = new Sound();\r
+                       mySound.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);\r
+                       mySound.addEventListener(Event.OPEN, loadOpen);\r
+                       mySound.addEventListener(Event.COMPLETE, loadComplete);\r
+                       myRequest = new URLRequest(src);\r
+                       myStatus.reset();\r
+                       myStatus.src = src;\r
+                       myStatus.srcSet = true;\r
+                       timeUpdateEvent();\r
+               }\r
+               public function clearFile():void {\r
+                       setFile("");\r
+                       myStatus.srcSet = false;\r
+               }\r
+               private function errorHandler(err:IOErrorEvent):void {\r
+                       // MP3 player needs to stop progress and timeupdate events as they are started before the error occurs.\r
+                       // NB: The MP4 player works differently and the error occurs before they are started.\r
+                       progressUpdates(false);\r
+                       timeUpdates(false);\r
+                       myStatus.error(); // Resets status except the src, and it sets srcError property.\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_ERROR, myStatus));\r
+               }\r
+               private function loadOpen(e:Event):void {\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "loadOpen:"));\r
+                       myStatus.loading();\r
+                       if(myStatus.playOnLoad) {\r
+                               myStatus.playOnLoad = false; // Capture the flag\r
+                               this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_LOADSTART, myStatus)); // So loadstart event happens before play event occurs.\r
+                               play();\r
+                       } else {\r
+                               this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_LOADSTART, myStatus));\r
+                               pause();\r
+                       }\r
+                       progressUpdates(true);\r
+               }\r
+               private function loadComplete(e:Event):void {\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "loadComplete:"));\r
+                       myStatus.loaded();\r
+                       progressUpdates(false);\r
+                       progressEvent();\r
+               }\r
+               private function soundCompleteHandler(e:Event):void {\r
+                       myStatus.pausePosition = 0;\r
+                       myStatus.isPlaying = false;\r
+                       timeUpdates(false);\r
+                       timeUpdateEvent();\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_ENDED, myStatus));\r
+               }\r
+               private function progressUpdates(active:Boolean):void {\r
+                       // Using a timer rather than Flash's load progress event, because that event gave data at about 200Hz. The 10Hz timer is closer to HTML5 norm.\r
+                       if(active) {\r
+                               progressTimer.start();\r
+                       } else {\r
+                               progressTimer.stop();\r
+                       }\r
+               }\r
+               private function progressHandler(e:TimerEvent):void {\r
+                       progressEvent();\r
+               }\r
+               private function progressEvent():void {\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "progressEvent:"));\r
+                       updateStatusValues();\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PROGRESS, myStatus));\r
+               }\r
+               private function timeUpdates(active:Boolean):void {\r
+                       if(active) {\r
+                               timeUpdateTimer.start();\r
+                       } else {\r
+                               timeUpdateTimer.stop();\r
+                       }\r
+               }\r
+               private function timeUpdateHandler(e:TimerEvent):void {\r
+                       timeUpdateEvent();\r
+               }\r
+               private function timeUpdateEvent():void {\r
+                       updateStatusValues();\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_TIMEUPDATE, myStatus));\r
+               }\r
+               private function seeking(active:Boolean):void {\r
+                       if(active) {\r
+                               if(!myStatus.isSeeking) {\r
+                                       seekingEvent();\r
+                                       seekingTimer.start();\r
+                               }\r
+                       } else {\r
+                               seekingTimer.stop();\r
+                       }\r
+               }\r
+               private function seekingHandler(e:TimerEvent):void {\r
+                       if(myStatus.pausePosition <= getDuration()) {\r
+                               seekedEvent();\r
+                               seeking(false);\r
+                               if(myStatus.playOnSeek) {\r
+                                       myStatus.playOnSeek = false; // Capture the flag.\r
+                                       play();\r
+                               }\r
+                       } else if(myStatus.isLoaded && (myStatus.pausePosition > getDuration())) {\r
+                               // Illegal seek time\r
+                               seeking(false);\r
+                               seekedEvent();\r
+                               pause(0);\r
+                       }\r
+               }\r
+               private function seekingEvent():void {\r
+                       myStatus.isSeeking = true;\r
+                       updateStatusValues();\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_SEEKING, myStatus));\r
+               }\r
+               private function seekedEvent():void {\r
+                       myStatus.isSeeking = false;\r
+                       updateStatusValues();\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_SEEKED, myStatus));\r
+               }\r
+               public function load():Boolean {\r
+                       if(myStatus.loadRequired()) {\r
+                               myStatus.startingDownload();\r
+                               mySound.load(myRequest, myContext);\r
+                               return true;\r
+                       } else {\r
+                               return false;\r
+                       }\r
+               }\r
+               public function play(time:Number = NaN):Boolean {\r
+                       var wasPlaying:Boolean = myStatus.isPlaying;\r
+\r
+                       if(!isNaN(time) && myStatus.srcSet) {\r
+                               if(myStatus.isPlaying) {\r
+                                       myChannel.stop();\r
+                                       myStatus.isPlaying = false;\r
+                               }\r
+                               myStatus.pausePosition = time;\r
+                       }\r
+\r
+                       if(myStatus.isStartingDownload) {\r
+                               myStatus.playOnLoad = true; // Raise flag, captured in loadOpen()\r
+                               return true;\r
+                       } else if(myStatus.loadRequired()) {\r
+                               myStatus.playOnLoad = true; // Raise flag, captured in loadOpen()\r
+                               return load();\r
+                       } else if((myStatus.isLoading || myStatus.isLoaded) && !myStatus.isPlaying) {\r
+                               if(myStatus.isLoaded && myStatus.pausePosition > getDuration()) { // The time is invalid, ie., past the end.\r
+                                       myStatus.pausePosition = 0;\r
+                                       timeUpdates(false);\r
+                                       timeUpdateEvent();\r
+                                       if(wasPlaying) { // For when playing and then get a play(huge)\r
+                                               this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PAUSE, myStatus));\r
+                                       }\r
+                               } else if(myStatus.pausePosition > getDuration()) {\r
+                                       myStatus.playOnSeek = true;\r
+                                       seeking(true);\r
+                               } else {\r
+                                       myStatus.isPlaying = true; // Set immediately before playing. Could affects events.\r
+                                       myChannel = mySound.play(myStatus.pausePosition);\r
+                                       myChannel.soundTransform = myTransform;\r
+                                       myChannel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);\r
+                                       timeUpdates(true);\r
+                                       if(!wasPlaying) {\r
+                                               this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PLAY, myStatus));\r
+                                       }\r
+                               }\r
+                               return true;\r
+                       } else {\r
+                               return false;\r
+                       }\r
+               }\r
+               public function pause(time:Number = NaN):Boolean {\r
+                       myStatus.playOnLoad = false; // Reset flag in case load/play issued immediately before this command, ie., before loadOpen() event.\r
+                       myStatus.playOnSeek = false; // Reset flag in case play(time) issued before the command and is still seeking to time set.\r
+\r
+                       var wasPlaying:Boolean = myStatus.isPlaying;\r
+\r
+                       // To avoid possible loops with timeupdate and pause(time). A pause() does not have the problem.\r
+                       var alreadyPausedAtTime:Boolean = false;\r
+                       if(!isNaN(time) && myStatus.pausePosition == time) {\r
+                               alreadyPausedAtTime = true;\r
+                       }\r
+\r
+                       if(myStatus.isPlaying) {\r
+                               myStatus.isPlaying = false;\r
+                               myChannel.stop();\r
+                               if(myChannel.position > 0) { // Required otherwise a fast play then pause causes myChannel.position to equal zero and not the correct value. ie., When it happens leave pausePosition alone.\r
+                                       myStatus.pausePosition = myChannel.position;\r
+                               }\r
+                       }\r
+\r
+                       if(!isNaN(time) && myStatus.srcSet) {\r
+                               myStatus.pausePosition = time;\r
+                       }\r
+\r
+                       if(wasPlaying) {\r
+                               this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PAUSE, myStatus));\r
+                       }\r
+                       \r
+                       if(myStatus.isStartingDownload) {\r
+                               return true;\r
+                       } else if(myStatus.loadRequired()) {\r
+                               if(time > 0) { // We do not want the stop() command, which does pause(0), causing a load operation.\r
+                                       return load();\r
+                               } else {\r
+                                       return true; // Technically the pause(0) succeeded. ie., It did nothing, since nothing was required.\r
+                               }\r
+                       } else if(myStatus.isLoading || myStatus.isLoaded) {\r
+                               if(myStatus.isLoaded && myStatus.pausePosition > getDuration()) { // The time is invalid, ie., past the end.\r
+                                       myStatus.pausePosition = 0;\r
+                               } else if(myStatus.pausePosition > getDuration()) {\r
+                                       seeking(true);\r
+                               }\r
+                               timeUpdates(false);\r
+                               // Need to be careful with timeupdate event, otherwise a pause in a timeupdate event can cause a loop.\r
+                               // Neither pause() nor pause(time) will cause a timeupdate loop.\r
+                               if(wasPlaying || !isNaN(time) && !alreadyPausedAtTime) {\r
+                                       timeUpdateEvent();\r
+                               }\r
+                               return true;\r
+                       } else {\r
+                               return false;\r
+                       }\r
+               }\r
+               public function playHead(percent:Number):Boolean {\r
+                       var time:Number = percent * getDuration() / 100;\r
+                       if(myStatus.isPlaying || myStatus.playOnLoad || myStatus.playOnSeek) {\r
+                               return play(time);\r
+                       } else {\r
+                               return pause(time);\r
+                       }\r
+               }\r
+               public function setVolume(v:Number):void {\r
+                       myStatus.volume = v;\r
+                       myTransform.volume = v;\r
+                       myChannel.soundTransform = myTransform;\r
+               }\r
+               private function updateStatusValues():void {\r
+                       myStatus.seekPercent = 100 * getLoadRatio();\r
+                       myStatus.currentTime = getCurrentTime();\r
+                       myStatus.currentPercentRelative = 100 * getCurrentRatioRel();\r
+                       myStatus.currentPercentAbsolute = 100 * getCurrentRatioAbs();\r
+                       myStatus.duration = getDuration();\r
+               }\r
+               public function getLoadRatio():Number {\r
+                       if((myStatus.isLoading || myStatus.isLoaded) && mySound.bytesTotal > 0) {\r
+                               return mySound.bytesLoaded / mySound.bytesTotal;\r
+                       } else {\r
+                               return 0;\r
+                       }\r
+               }\r
+               public function getDuration():Number {\r
+                       if(mySound.length > 0) {\r
+                               return mySound.length;\r
+                       } else {\r
+                               return 0;\r
+                       }\r
+               }\r
+               public function getCurrentTime():Number {\r
+                       if(myStatus.isPlaying) {\r
+                               return myChannel.position;\r
+                       } else {\r
+                               return myStatus.pausePosition;\r
+                       }\r
+               }\r
+               public function getCurrentRatioRel():Number {\r
+                       if((getDuration() > 0) && (getCurrentTime() <= getDuration())) {\r
+                               return getCurrentTime() / getDuration();\r
+                       } else {\r
+                               return 0;\r
+                       }\r
+               }\r
+               public function getCurrentRatioAbs():Number {\r
+                       return getCurrentRatioRel() * getLoadRatio();\r
+               }\r
+       }\r
+}\r
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp4.as b/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerMp4.as
new file mode 100644 (file)
index 0000000..dcdc065
--- /dev/null
@@ -0,0 +1,413 @@
+/*\r
+ * jPlayer Plugin for jQuery JavaScript Library\r
+ * http://www.happyworm.com/jquery/jplayer\r
+ *\r
+ * Copyright (c) 2009 - 2011 Happyworm Ltd\r
+ * Dual licensed under the MIT and GPL licenses.\r
+ *  - http://www.opensource.org/licenses/mit-license.php\r
+ *  - http://www.gnu.org/copyleft/gpl.html\r
+ *\r
+ * Author: Mark J Panaghiston\r
+ * Date: 7th August 2011\r
+ */\r
+\r
+package happyworm.jPlayer {\r
+       import flash.display.Sprite;\r
+\r
+       import flash.media.Video;\r
+       import flash.media.SoundTransform;\r
+\r
+       import flash.net.NetConnection;\r
+       import flash.net.NetStream;\r
+\r
+       import flash.utils.Timer;\r
+\r
+       import flash.events.NetStatusEvent;\r
+       import flash.events.SecurityErrorEvent;\r
+       import flash.events.TimerEvent;\r
+\r
+       public class JplayerMp4 extends Sprite {\r
+               \r
+               public var myVideo:Video = new Video();\r
+               private var myConnection:NetConnection;\r
+               private var myStream:NetStream;\r
+               \r
+               private var myTransform:SoundTransform = new SoundTransform();\r
+\r
+               public var myStatus:JplayerStatus = new JplayerStatus();\r
+               \r
+               private var timeUpdateTimer:Timer = new Timer(250, 0); // Matched to HTML event freq\r
+               private var progressTimer:Timer = new Timer(250, 0); // Matched to HTML event freq\r
+               private var seekingTimer:Timer = new Timer(100, 0); // Internal: How often seeking is checked to see if it is over.\r
+\r
+               public function JplayerMp4(volume:Number) {\r
+                       myConnection = new NetConnection();\r
+                       myConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);\r
+                       myConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);\r
+                       myVideo.smoothing = true;\r
+                       this.addChild(myVideo);\r
+                       \r
+                       timeUpdateTimer.addEventListener(TimerEvent.TIMER, timeUpdateHandler);\r
+                       progressTimer.addEventListener(TimerEvent.TIMER, progressHandler);\r
+                       seekingTimer.addEventListener(TimerEvent.TIMER, seekingHandler);\r
+\r
+                       myStatus.volume = volume;\r
+               }\r
+               private function progressUpdates(active:Boolean):void {\r
+                       if(active) {\r
+                               progressTimer.start();\r
+                       } else {\r
+                               progressTimer.stop();\r
+                       }\r
+               }\r
+               private function progressHandler(e:TimerEvent):void {\r
+                       if(myStatus.isLoading) {\r
+                               if(getLoadRatio() == 1) { // Close as can get to a loadComplete event since client.onPlayStatus only works with FMS\r
+                                       this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "progressHandler: loadComplete"));\r
+                                       myStatus.loaded();\r
+                                       progressUpdates(false);\r
+                               }\r
+                       }\r
+                       progressEvent();\r
+               }\r
+               private function progressEvent():void {\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "progressEvent:"));\r
+                       updateStatusValues();\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PROGRESS, myStatus));\r
+               }\r
+               private function timeUpdates(active:Boolean):void {\r
+                       if(active) {\r
+                               timeUpdateTimer.start();\r
+                       } else {\r
+                               timeUpdateTimer.stop();\r
+                       }\r
+               }\r
+               private function timeUpdateHandler(e:TimerEvent):void {\r
+                       timeUpdateEvent();\r
+               }\r
+               private function timeUpdateEvent():void {\r
+                       updateStatusValues();\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_TIMEUPDATE, myStatus));\r
+               }\r
+               private function seeking(active:Boolean):void {\r
+                       if(active) {\r
+                               if(!myStatus.isSeeking) {\r
+                                       seekingEvent();\r
+                               }\r
+                               seekingTimer.start();\r
+                       } else {\r
+                               if(myStatus.isSeeking) {\r
+                                       seekedEvent();\r
+                               }\r
+                               seekingTimer.stop();\r
+                       }\r
+               }\r
+               private function seekingHandler(e:TimerEvent):void {\r
+                       if(getSeekTimeRatio() <= getLoadRatio()) {\r
+                               seeking(false);\r
+                               if(myStatus.playOnSeek) {\r
+                                       myStatus.playOnSeek = false; // Capture the flag.\r
+                                       play(myStatus.pausePosition); // Must pass time or the seek time is never set.\r
+                               } else {\r
+                                       pause(myStatus.pausePosition); // Must pass time or the stream.time is read.\r
+                               }\r
+                       } else if(myStatus.metaDataReady && myStatus.pausePosition > myStatus.duration) {\r
+                               // Illegal seek time\r
+                               seeking(false);\r
+                               pause(0);\r
+                       }\r
+               }\r
+               private function seekingEvent():void {\r
+                       myStatus.isSeeking = true;\r
+                       updateStatusValues();\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_SEEKING, myStatus));\r
+               }\r
+               private function seekedEvent():void {\r
+                       myStatus.isSeeking = false;\r
+                       updateStatusValues();\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_SEEKED, myStatus));\r
+               }\r
+               private function netStatusHandler(e:NetStatusEvent):void {\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "netStatusHandler: '" + e.info.code + "'"));\r
+                       switch(e.info.code) {\r
+                               case "NetConnection.Connect.Success":\r
+                                       connectStream();\r
+                                       break;\r
+                               case "NetStream.Play.Start":\r
+                                       // This event code occurs once, when the media is opened. Equiv to loadOpen() in mp3 player.\r
+                                       myStatus.loading();\r
+                                       this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_LOADSTART, myStatus));\r
+                                       progressUpdates(true);\r
+                                       // See onMetaDataHandler() for other condition, since duration is vital.\r
+                                       break;\r
+                               case "NetStream.Play.Stop":\r
+                                       this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "NetStream.Play.Stop: getDuration() - getCurrentTime() = " + (getDuration() - getCurrentTime())));\r
+\r
+                                       // Check if media is at the end (or close) otherwise this was due to download bandwidth stopping playback. ie., Download is not fast enough.\r
+                                       if(Math.abs(getDuration() - getCurrentTime()) < 150) { // Testing found 150ms worked best for M4A files, where playHead(99.9) caused a stuck state due to firing with ~116ms left to play.\r
+                                               endedEvent();\r
+                                       }\r
+                                       break;\r
+                               case "NetStream.Seek.InvalidTime":\r
+                                       // Used for capturing invalid set times and clicks on the end of the progress bar.\r
+                                       endedEvent();\r
+                                       break;\r
+                               case "NetStream.Play.StreamNotFound":\r
+                                       myStatus.error(); // Resets status except the src, and it sets srcError property.\r
+                                       this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_ERROR, myStatus));\r
+                                       break;\r
+                       }\r
+                       // "NetStream.Seek.Notify" event code is not very useful. It occurs after every seek(t) command issued and does not appear to wait for the media to be ready.\r
+               }\r
+               private function endedEvent():void {\r
+                       var wasPlaying:Boolean = myStatus.isPlaying;\r
+                       pause(0);\r
+                       timeUpdates(false);\r
+                       timeUpdateEvent();\r
+                       if(wasPlaying) {\r
+                               this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_ENDED, myStatus));\r
+                       }\r
+               }\r
+               private function securityErrorHandler(event:SecurityErrorEvent):void {\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "securityErrorHandler."));\r
+               }\r
+               private function connectStream():void {\r
+                       this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "connectStream."));\r
+                       var customClient:Object = new Object();\r
+                       customClient.onMetaData = onMetaDataHandler;\r
+                       // customClient.onPlayStatus = onPlayStatusHandler; // According to the forums and my tests, onPlayStatus only works with FMS (Flash Media Server).\r
+                       myStream = null;\r
+                       myStream = new NetStream(myConnection);\r
+                       myStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);\r
+                       myStream.client = customClient;\r
+                       myVideo.attachNetStream(myStream);\r
+                       setVolume(myStatus.volume);\r
+                       myStream.play(myStatus.src);\r
+               }\r
+               public function setFile(src:String):void {\r
+                       if(myStream != null) {\r
+                               myStream.close();\r
+                       }\r
+                       myVideo.clear();\r
+                       progressUpdates(false);\r
+                       timeUpdates(false);\r
+\r
+                       myStatus.reset();\r
+                       myStatus.src = src;\r
+                       myStatus.srcSet = true;\r
+                       timeUpdateEvent();\r
+               }\r
+               public function clearFile():void {\r
+                       setFile("");\r
+                       myStatus.srcSet = false;\r
+               }\r
+               public function load():Boolean {\r
+                       if(myStatus.loadRequired()) {\r
+                               myStatus.startingDownload();\r
+                               myConnection.connect(null);\r
+                               return true;\r
+                       } else {\r
+                               return false;\r
+                       }\r
+               }\r
+               public function play(time:Number = NaN):Boolean {\r
+                       var wasPlaying:Boolean = myStatus.isPlaying;\r
+\r
+                       if(!isNaN(time) && myStatus.srcSet) {\r
+                               if(myStatus.isPlaying) {\r
+                                       myStream.pause();\r
+                                       myStatus.isPlaying = false;\r
+                               }\r
+                               myStatus.pausePosition = time;\r
+                       }\r
+\r
+                       if(myStatus.isStartingDownload) {\r
+                               myStatus.playOnLoad = true; // Raise flag, captured in onMetaDataHandler()\r
+                               return true;\r
+                       } else if(myStatus.loadRequired()) {\r
+                               myStatus.playOnLoad = true; // Raise flag, captured in onMetaDataHandler()\r
+                               return load();\r
+                       } else if((myStatus.isLoading || myStatus.isLoaded) && !myStatus.isPlaying) {\r
+                               if(myStatus.metaDataReady && myStatus.pausePosition > myStatus.duration) { // The time is invalid, ie., past the end.\r
+                                       myStream.pause(); // Since it is playing by default at this point.\r
+                                       myStatus.pausePosition = 0;\r
+                                       myStream.seek(0);\r
+                                       timeUpdates(false);\r
+                                       timeUpdateEvent();\r
+                                       if(wasPlaying) { // For when playing and then get a play(huge)\r
+                                               this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PAUSE, myStatus));\r
+                                       }\r
+                               } else if(getSeekTimeRatio() > getLoadRatio()) { // Use an estimate based on the downloaded amount\r
+                                       myStatus.playOnSeek = true;\r
+                                       seeking(true);\r
+                                       myStream.pause(); // Since it is playing by default at this point.\r
+                               } else {\r
+                                       if(!isNaN(time)) { // Avoid using seek() when it is already correct.\r
+                                               myStream.seek(myStatus.pausePosition/1000); // Since time is in ms and seek() takes seconds\r
+                                       }\r
+                                       myStatus.isPlaying = true; // Set immediately before playing. Could affects events.\r
+                                       myStream.resume();\r
+                                       timeUpdates(true);\r
+                                       if(!wasPlaying) {\r
+                                               this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PLAY, myStatus));\r
+                                       }\r
+                               }\r
+                               return true;\r
+                       } else {\r
+                               return false;\r
+                       }\r
+               }\r
+               public function pause(time:Number = NaN):Boolean {\r
+                       myStatus.playOnLoad = false; // Reset flag in case load/play issued immediately before this command, ie., before onMetadata() event.\r
+                       myStatus.playOnSeek = false; // Reset flag in case play(time) issued before the command and is still seeking to time set.\r
+\r
+                       var wasPlaying:Boolean = myStatus.isPlaying;\r
+\r
+                       // To avoid possible loops with timeupdate and pause(time). A pause() does not have the problem.\r
+                       var alreadyPausedAtTime:Boolean = false;\r
+                       if(!isNaN(time) && myStatus.pausePosition == time) {\r
+                               alreadyPausedAtTime = true;\r
+                       }\r
+\r
+                       // Need to wait for metadata to load before ever issuing a pause. The metadata handler will call this function if needed, when ready.\r
+                       if(myStream != null && myStatus.metaDataReady) { // myStream is a null until the 1st media is loaded. ie., The 1st ever setMedia being followed by a pause() or pause(t).\r
+                               myStream.pause();\r
+                       }\r
+                       if(myStatus.isPlaying) {\r
+                               myStatus.isPlaying = false;\r
+                               myStatus.pausePosition = myStream.time * 1000;\r
+                       }\r
+                       \r
+                       if(!isNaN(time) && myStatus.srcSet) {\r
+                               myStatus.pausePosition = time;\r
+                       }\r
+\r
+                       if(wasPlaying) {\r
+                               this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_PAUSE, myStatus));\r
+                       }\r
+\r
+                       if(myStatus.isStartingDownload) {\r
+                               return true;\r
+                       } else if(myStatus.loadRequired()) {\r
+                               if(time > 0) { // We do not want the stop() command, which does pause(0), causing a load operation.\r
+                                       return load();\r
+                               } else {\r
+                                       return true; // Technically the pause(0) succeeded. ie., It did nothing, since nothing was required.\r
+                               }\r
+                       } else if(myStatus.isLoading || myStatus.isLoaded) {\r
+                               if(myStatus.metaDataReady && myStatus.pausePosition > myStatus.duration) { // The time is invalid, ie., past the end.\r
+                                       myStatus.pausePosition = 0;\r
+                                       myStream.seek(0);\r
+                                       seekedEvent(); // Deals with seeking effect when using setMedia() then pause(huge). NB: There is no preceeding seeking event.\r
+                               } else if(!isNaN(time)) {\r
+                                       if(getSeekTimeRatio() > getLoadRatio()) { // Use an estimate based on the downloaded amount\r
+                                               seeking(true);\r
+                                       } else {\r
+                                               if(myStatus.metaDataReady) { // Otherwise seek(0) will stop the metadata loading.\r
+                                                       myStream.seek(myStatus.pausePosition/1000);\r
+                                               }\r
+                                       }\r
+                               }\r
+                               timeUpdates(false);\r
+                               // Need to be careful with timeupdate event, otherwise a pause in a timeupdate event can cause a loop.\r
+                               // Neither pause() nor pause(time) will cause a timeupdate loop.\r
+                               if(wasPlaying || !isNaN(time) && !alreadyPausedAtTime) {\r
+                                       timeUpdateEvent();\r
+                               }\r
+                               return true;\r
+                       } else {\r
+                               return false;\r
+                       }\r
+               }\r
+               public function playHead(percent:Number):Boolean {\r
+                       var time:Number = percent * getDuration() * getLoadRatio() / 100;\r
+                       if(myStatus.isPlaying || myStatus.playOnLoad || myStatus.playOnSeek) {\r
+                               return play(time);\r
+                       } else {\r
+                               return pause(time);\r
+                       }\r
+               }\r
+               public function setVolume(v:Number):void {\r
+                       myStatus.volume = v;\r
+                       myTransform.volume = v;\r
+                       if(myStream != null) {\r
+                               myStream.soundTransform = myTransform;\r
+                       }\r
+               }\r
+               private function updateStatusValues():void {\r
+                       myStatus.seekPercent = 100 * getLoadRatio();\r
+                       myStatus.currentTime = getCurrentTime();\r
+                       myStatus.currentPercentRelative = 100 * getCurrentRatioRel();\r
+                       myStatus.currentPercentAbsolute = 100 * getCurrentRatioAbs();\r
+                       myStatus.duration = getDuration();\r
+               }\r
+               public function getLoadRatio():Number {\r
+                       if((myStatus.isLoading || myStatus.isLoaded) && myStream.bytesTotal > 0) {\r
+                               return myStream.bytesLoaded / myStream.bytesTotal;\r
+                       } else {\r
+                               return 0;\r
+                       }\r
+               }\r
+               public function getDuration():Number {\r
+                       return myStatus.duration; // Set from meta data.\r
+               }\r
+               public function getCurrentTime():Number {\r
+                       if(myStatus.isPlaying) {\r
+                               return myStream.time * 1000;\r
+                       } else {\r
+                               return myStatus.pausePosition;\r
+                       }\r
+               }\r
+               public function getCurrentRatioRel():Number {\r
+                       if((getLoadRatio() > 0) && (getCurrentRatioAbs() <= getLoadRatio())) {\r
+                               return getCurrentRatioAbs() / getLoadRatio();\r
+                       } else {\r
+                               return 0;\r
+                       }\r
+               }\r
+               public function getCurrentRatioAbs():Number {\r
+                       if(getDuration() > 0) {\r
+                               return getCurrentTime() / getDuration();\r
+                       } else {\r
+                               return 0;\r
+                       }\r
+               }\r
+               public function getSeekTimeRatio():Number {\r
+                       if(getDuration() > 0) {\r
+                               return myStatus.pausePosition / getDuration();\r
+                       } else {\r
+                               return 1;\r
+                       }\r
+               }\r
+               public function onMetaDataHandler(info:Object):void { // Used in connectStream() in myStream.client object.\r
+                       // This event occurs when jumping to the start of static files! ie., seek(0) will cause this event to occur.\r
+                       if(!myStatus.metaDataReady) {\r
+                               this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "onMetaDataHandler: " + info.duration + " | " + info.width + "x" + info.height));\r
+\r
+                               myStatus.metaDataReady = true; // Set flag so that this event only effects jPlayer the 1st time.\r
+                               myStatus.metaData = info;\r
+                               myStatus.duration = info.duration * 1000; // Only available via Meta Data.\r
+                               if(info.width != undefined) {\r
+                                       myVideo.width = info.width;\r
+                               }\r
+                               if(info.height != undefined) {\r
+                                       myVideo.height = info.height;\r
+                               }\r
+\r
+                               if(myStatus.playOnLoad) {\r
+                                       myStatus.playOnLoad = false; // Capture the flag\r
+                                       if(myStatus.pausePosition > 0 ) { // Important for setMedia followed by play(time).\r
+                                               play(myStatus.pausePosition);\r
+                                       } else {\r
+                                               play(); // Not always sending pausePosition avoids the extra seek(0) for a normal play() command.\r
+                                       }\r
+                               } else {\r
+                                       pause(myStatus.pausePosition); // Always send the pausePosition. Important for setMedia() followed by pause(time). Deals with not reading stream.time with setMedia() and play() immediately followed by stop() or pause(0)\r
+                               }\r
+                               this.dispatchEvent(new JplayerEvent(JplayerEvent.JPLAYER_LOADEDMETADATA, myStatus));\r
+                       } else {\r
+                               this.dispatchEvent(new JplayerEvent(JplayerEvent.DEBUG_MSG, myStatus, "onMetaDataHandler: Already read (NO EFFECT)"));\r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerStatus.as b/apps/media/js/jQuery.jPlayer.2.1.0.source/happyworm/jPlayer/JplayerStatus.as
new file mode 100644 (file)
index 0000000..5cc1e1f
--- /dev/null
@@ -0,0 +1,101 @@
+/*\r
+ * jPlayer Plugin for jQuery JavaScript Library\r
+ * http://www.happyworm.com/jquery/jplayer\r
+ *\r
+ * Copyright (c) 2009 - 2011 Happyworm Ltd\r
+ * Dual licensed under the MIT and GPL licenses.\r
+ *  - http://www.opensource.org/licenses/mit-license.php\r
+ *  - http://www.gnu.org/copyleft/gpl.html\r
+ *\r
+ * Author: Mark J Panaghiston\r
+ * Date: 1st September 2011\r
+ */\r
+\r
+package happyworm.jPlayer {\r
+       public class JplayerStatus {\r
+\r
+               public static const VERSION:String = "2.1.0"; // The version of the Flash jPlayer entity.\r
+\r
+               public var volume:Number = 0.5; // Not affected by reset()\r
+               public var muted:Boolean = false; // Not affected by reset()\r
+\r
+               public var src:String;\r
+               public var srcError:Boolean;\r
+\r
+               public var srcSet:Boolean;\r
+               public var isPlaying:Boolean;\r
+               public var isSeeking:Boolean;\r
+\r
+               public var playOnLoad:Boolean;\r
+               public var playOnSeek:Boolean;\r
+\r
+               public var isStartingDownload:Boolean;\r
+               public var isLoading:Boolean;\r
+               public var isLoaded:Boolean;\r
+\r
+               public var pausePosition:Number;\r
+\r
+               public var seekPercent:Number;\r
+               public var currentTime:Number;\r
+               public var currentPercentRelative:Number;\r
+               public var currentPercentAbsolute:Number;\r
+               public var duration:Number;\r
+               \r
+               public var metaDataReady:Boolean;\r
+               public var metaData:Object;\r
+\r
+               public function JplayerStatus() {\r
+                       reset();\r
+               }\r
+               public function reset():void {\r
+                       src = "";\r
+                       srcError = false;\r
+\r
+                       srcSet = false;\r
+                       isPlaying = false;\r
+                       isSeeking = false;\r
+\r
+                       playOnLoad = false;\r
+                       playOnSeek = false;\r
+\r
+                       isStartingDownload = false;\r
+                       isLoading = false;\r
+                       isLoaded = false;\r
+\r
+                       pausePosition = 0;\r
+\r
+                       seekPercent = 0;\r
+                       currentTime = 0;\r
+                       currentPercentRelative = 0;\r
+                       currentPercentAbsolute = 0;\r
+                       duration = 0;\r
+                       \r
+                       metaDataReady = false;\r
+                       metaData = {};\r
+               }\r
+               public function error():void {\r
+                       var srcSaved:String = src;\r
+                       reset();\r
+                       src = srcSaved;\r
+                       srcError = true;\r
+               }\r
+               public function loadRequired():Boolean {\r
+                       return (srcSet && !isStartingDownload && !isLoading && !isLoaded);\r
+               }\r
+               public function startingDownload():void {\r
+                       isStartingDownload = true;\r
+                       isLoading = false;\r
+                       isLoaded = false;\r
+               }\r
+               public function loading():void {\r
+                       isStartingDownload = false;\r
+                       isLoading = true;\r
+                       isLoaded = false;\r
+               }\r
+               public function loaded():void {\r
+                       isStartingDownload = false;\r
+                       isLoading = false;\r
+                       isLoaded = true;\r
+               }\r
+       }\r
+}\r
diff --git a/apps/media/js/jQuery.jPlayer.2.1.0.source/jquery.jplayer.js b/apps/media/js/jQuery.jPlayer.2.1.0.source/jquery.jplayer.js
new file mode 100644 (file)
index 0000000..9d41a12
--- /dev/null
@@ -0,0 +1,2349 @@
+/*\r
+ * jPlayer Plugin for jQuery JavaScript Library\r
+ * http://www.jplayer.org\r
+ *\r
+ * Copyright (c) 2009 - 2011 Happyworm Ltd\r
+ * Dual licensed under the MIT and GPL licenses.\r
+ *  - http://www.opensource.org/licenses/mit-license.php\r
+ *  - http://www.gnu.org/copyleft/gpl.html\r
+ *\r
+ * Author: Mark J Panaghiston\r
+ * Version: 2.1.0\r
+ * Date: 1st September 2011\r
+ */\r
+\r
+/* Code verified using http://www.jshint.com/ */\r
+/*jshint asi:false, bitwise:false, boss:false, browser:true, curly:true, debug:false, eqeqeq:true, eqnull:false, evil:false, forin:false, immed:false, jquery:true, laxbreak:false, newcap:true, noarg:true, noempty:true, nonew:true, nomem:false, onevar:false, passfail:false, plusplus:false, regexp:false, undef:true, sub:false, strict:false, white:false */\r
+/*global jQuery:false, ActiveXObject:false, alert:false */\r
+\r
+(function($, undefined) {\r
+\r
+       // Adapted from jquery.ui.widget.js (1.8.7): $.widget.bridge\r
+       $.fn.jPlayer = function( options ) {\r
+               var name = "jPlayer";\r
+               var isMethodCall = typeof options === "string",\r
+                       args = Array.prototype.slice.call( arguments, 1 ),\r
+                       returnValue = this;\r
+\r
+               // allow multiple hashes to be passed on init\r
+               options = !isMethodCall && args.length ?\r
+                       $.extend.apply( null, [ true, options ].concat(args) ) :\r
+                       options;\r
+\r
+               // prevent calls to internal methods\r
+               if ( isMethodCall && options.charAt( 0 ) === "_" ) {\r
+                       return returnValue;\r
+               }\r
+\r
+               if ( isMethodCall ) {\r
+                       this.each(function() {\r
+                               var instance = $.data( this, name ),\r
+                                       methodValue = instance && $.isFunction( instance[options] ) ?\r
+                                               instance[ options ].apply( instance, args ) :\r
+                                               instance;\r
+                               if ( methodValue !== instance && methodValue !== undefined ) {\r
+                                       returnValue = methodValue;\r
+                                       return false;\r
+                               }\r
+                       });\r
+               } else {\r
+                       this.each(function() {\r
+                               var instance = $.data( this, name );\r
+                               if ( instance ) {\r
+                                       // instance.option( options || {} )._init(); // Orig jquery.ui.widget.js code: Not recommend for jPlayer. ie., Applying new options to an existing instance (via the jPlayer constructor) and performing the _init(). The _init() is what concerns me. It would leave a lot of event handlers acting on jPlayer instance and the interface.\r
+                                       instance.option( options || {} ); // The new constructor only changes the options. Changing options only has basic support atm.\r
+                               } else {\r
+                                       $.data( this, name, new $.jPlayer( options, this ) );\r
+                               }\r
+                       });\r
+               }\r
+\r
+               return returnValue;\r
+       };\r
+\r
+       $.jPlayer = function( options, element ) {\r
+               // allow instantiation without initializing for simple inheritance\r
+               if ( arguments.length ) {\r
+                       this.element = $(element);\r
+                       this.options = $.extend(true, {},\r
+                               this.options,\r
+                               options\r
+                       );\r
+                       var self = this;\r
+                       this.element.bind( "remove.jPlayer", function() {\r
+                               self.destroy();\r
+                       });\r
+                       this._init();\r
+               }\r
+       };\r
+       // End of: (Adapted from jquery.ui.widget.js (1.8.7))\r
+\r
+       // Emulated HTML5 methods and properties\r
+       $.jPlayer.emulateMethods = "load play pause";\r
+       $.jPlayer.emulateStatus = "src readyState networkState currentTime duration paused ended playbackRate";\r
+       $.jPlayer.emulateOptions = "muted volume";\r
+\r
+       // Reserved event names generated by jPlayer that are not part of the HTML5 Media element spec\r
+       $.jPlayer.reservedEvent = "ready flashreset resize repeat error warning";\r
+\r
+       // Events generated by jPlayer\r
+       $.jPlayer.event = {\r
+               ready: "jPlayer_ready",\r
+               flashreset: "jPlayer_flashreset", // Similar to the ready event if the Flash solution is set to display:none and then shown again or if it's reloaded for another reason by the browser. For example, using CSS position:fixed on Firefox for the full screen feature.\r
+               resize: "jPlayer_resize", // Occurs when the size changes through a full/restore screen operation or if the size/sizeFull options are changed.\r
+               repeat: "jPlayer_repeat", // Occurs when the repeat status changes. Usually through clicks on the repeat button of the interface.\r
+               click: "jPlayer_click", // Occurs when the user clicks on one of the following: poster image, html video, flash video.\r
+               error: "jPlayer_error", // Event error code in event.jPlayer.error.type. See $.jPlayer.error\r
+               warning: "jPlayer_warning", // Event warning code in event.jPlayer.warning.type. See $.jPlayer.warning\r
+\r
+               // Other events match HTML5 spec.\r
+               loadstart: "jPlayer_loadstart",\r
+               progress: "jPlayer_progress",\r
+               suspend: "jPlayer_suspend",\r
+               abort: "jPlayer_abort",\r
+               emptied: "jPlayer_emptied",\r
+               stalled: "jPlayer_stalled",\r
+               play: "jPlayer_play",\r
+               pause: "jPlayer_pause",\r
+               loadedmetadata: "jPlayer_loadedmetadata",\r
+               loadeddata: "jPlayer_loadeddata",\r
+               waiting: "jPlayer_waiting",\r
+               playing: "jPlayer_playing",\r
+               canplay: "jPlayer_canplay",\r
+               canplaythrough: "jPlayer_canplaythrough",\r
+               seeking: "jPlayer_seeking",\r
+               seeked: "jPlayer_seeked",\r
+               timeupdate: "jPlayer_timeupdate",\r
+               ended: "jPlayer_ended",\r
+               ratechange: "jPlayer_ratechange",\r
+               durationchange: "jPlayer_durationchange",\r
+               volumechange: "jPlayer_volumechange"\r
+       };\r
+\r
+       $.jPlayer.htmlEvent = [ // These HTML events are bubbled through to the jPlayer event, without any internal action.\r
+               "loadstart",\r
+               // "progress", // jPlayer uses internally before bubbling.\r
+               // "suspend", // jPlayer uses internally before bubbling.\r
+               "abort",\r
+               // "error", // jPlayer uses internally before bubbling.\r
+               "emptied",\r
+               "stalled",\r
+               // "play", // jPlayer uses internally before bubbling.\r
+               // "pause", // jPlayer uses internally before bubbling.\r
+               "loadedmetadata",\r
+               "loadeddata",\r
+               // "waiting", // jPlayer uses internally before bubbling.\r
+               // "playing", // jPlayer uses internally before bubbling.\r
+               "canplay",\r
+               "canplaythrough",\r
+               // "seeking", // jPlayer uses internally before bubbling.\r
+               // "seeked", // jPlayer uses internally before bubbling.\r
+               // "timeupdate", // jPlayer uses internally before bubbling.\r
+               // "ended", // jPlayer uses internally before bubbling.\r
+               "ratechange"\r
+               // "durationchange" // jPlayer uses internally before bubbling.\r
+               // "volumechange" // jPlayer uses internally before bubbling.\r
+       ];\r
+\r
+       $.jPlayer.pause = function() {\r
+               $.each($.jPlayer.prototype.instances, function(i, element) {\r
+                       if(element.data("jPlayer").status.srcSet) { // Check that media is set otherwise would cause error event.\r
+                               element.jPlayer("pause");\r
+                       }\r
+               });\r
+       };\r
+       \r
+       $.jPlayer.timeFormat = {\r
+               showHour: false,\r
+               showMin: true,\r
+               showSec: true,\r
+               padHour: false,\r
+               padMin: true,\r
+               padSec: true,\r
+               sepHour: ":",\r
+               sepMin: ":",\r
+               sepSec: ""\r
+       };\r
+\r
+       $.jPlayer.convertTime = function(s) {\r
+               var myTime = new Date(s * 1000);\r
+               var hour = myTime.getUTCHours();\r
+               var min = myTime.getUTCMinutes();\r
+               var sec = myTime.getUTCSeconds();\r
+               var strHour = ($.jPlayer.timeFormat.padHour && hour < 10) ? "0" + hour : hour;\r
+               var strMin = ($.jPlayer.timeFormat.padMin && min < 10) ? "0" + min : min;\r
+               var strSec = ($.jPlayer.timeFormat.padSec && sec < 10) ? "0" + sec : sec;\r
+               return (($.jPlayer.timeFormat.showHour) ? strHour + $.jPlayer.timeFormat.sepHour : "") + (($.jPlayer.timeFormat.showMin) ? strMin + $.jPlayer.timeFormat.sepMin : "") + (($.jPlayer.timeFormat.showSec) ? strSec + $.jPlayer.timeFormat.sepSec : "");\r
+       };\r
+\r
+       // Adapting jQuery 1.4.4 code for jQuery.browser. Required since jQuery 1.3.2 does not detect Chrome as webkit.\r
+       $.jPlayer.uaBrowser = function( userAgent ) {\r
+               var ua = userAgent.toLowerCase();\r
+\r
+               // Useragent RegExp\r
+               var rwebkit = /(webkit)[ \/]([\w.]+)/;\r
+               var ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/;\r
+               var rmsie = /(msie) ([\w.]+)/;\r
+               var rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/;\r
+\r
+               var match = rwebkit.exec( ua ) ||\r
+                       ropera.exec( ua ) ||\r
+                       rmsie.exec( ua ) ||\r
+                       ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||\r
+                       [];\r
+\r
+               return { browser: match[1] || "", version: match[2] || "0" };\r
+       };\r
+\r
+       // Platform sniffer for detecting mobile devices\r
+       $.jPlayer.uaPlatform = function( userAgent ) {\r
+               var ua = userAgent.toLowerCase();\r
+\r
+               // Useragent RegExp\r
+               var rplatform = /(ipad|iphone|ipod|android|blackberry|playbook|windows ce|webos)/;\r
+               var rtablet = /(ipad|playbook)/;\r
+               var randroid = /(android)/;\r
+               var rmobile = /(mobile)/;\r
+\r
+               var platform = rplatform.exec( ua ) || [];\r
+               var tablet = rtablet.exec( ua ) ||\r
+                       !rmobile.exec( ua ) && randroid.exec( ua ) ||\r
+                       [];\r
+\r
+               if(platform[1]) {\r
+                       platform[1] = platform[1].replace(/\s/g, "_"); // Change whitespace to underscore. Enables dot notation.\r
+               }\r
+\r
+               return { platform: platform[1] || "", tablet: tablet[1] || "" };\r
+       };\r
+\r
+       $.jPlayer.browser = {\r
+       };\r
+       $.jPlayer.platform = {\r
+       };\r
+\r
+       var browserMatch = $.jPlayer.uaBrowser(navigator.userAgent);\r
+       if ( browserMatch.browser ) {\r
+               $.jPlayer.browser[ browserMatch.browser ] = true;\r
+               $.jPlayer.browser.version = browserMatch.version;\r
+       }\r
+       var platformMatch = $.jPlayer.uaPlatform(navigator.userAgent);\r
+       if ( platformMatch.platform ) {\r
+               $.jPlayer.platform[ platformMatch.platform ] = true;\r
+               $.jPlayer.platform.mobile = !platformMatch.tablet;\r
+               $.jPlayer.platform.tablet = !!platformMatch.tablet;\r
+       }\r
+\r
+       $.jPlayer.prototype = {\r
+               count: 0, // Static Variable: Change it via prototype.\r
+               version: { // Static Object\r
+                       script: "2.1.0",\r
+                       needFlash: "2.1.0",\r
+                       flash: "unknown"\r
+               },\r
+               options: { // Instanced in $.jPlayer() constructor\r
+                       swfPath: "js", // Path to Jplayer.swf. Can be relative, absolute or server root relative.\r
+                       solution: "html, flash", // Valid solutions: html, flash. Order defines priority. 1st is highest,\r
+                       supplied: "mp3", // Defines which formats jPlayer will try and support and the priority by the order. 1st is highest,\r
+                       preload: 'metadata',  // HTML5 Spec values: none, metadata, auto.\r
+                       volume: 0.8, // The volume. Number 0 to 1.\r
+                       muted: false,\r
+                       wmode: "opaque", // Valid wmode: window, transparent, opaque, direct, gpu. \r
+                       backgroundColor: "#000000", // To define the jPlayer div and Flash background color.\r
+                       cssSelectorAncestor: "#jp_container_1",\r
+                       cssSelector: { // * denotes properties that should only be required when video media type required. _cssSelector() would require changes to enable splitting these into Audio and Video defaults.\r
+                               videoPlay: ".jp-video-play", // *\r
+                               play: ".jp-play",\r
+                               pause: ".jp-pause",\r
+                               stop: ".jp-stop",\r
+                               seekBar: ".jp-seek-bar",\r
+                               playBar: ".jp-play-bar",\r
+                               mute: ".jp-mute",\r
+                               unmute: ".jp-unmute",\r
+                               volumeBar: ".jp-volume-bar",\r
+                               volumeBarValue: ".jp-volume-bar-value",\r
+                               volumeMax: ".jp-volume-max",\r
+                               currentTime: ".jp-current-time",\r
+                               duration: ".jp-duration",\r
+                               fullScreen: ".jp-full-screen", // *\r
+                               restoreScreen: ".jp-restore-screen", // *\r
+                               repeat: ".jp-repeat",\r
+                               repeatOff: ".jp-repeat-off",\r
+                               gui: ".jp-gui", // The interface used with autohide feature.\r
+                               noSolution: ".jp-no-solution" // For error feedback when jPlayer cannot find a solution.\r
+                       },\r
+                       fullScreen: false,\r
+                       autohide: {\r
+                               restored: false, // Controls the interface autohide feature.\r
+                               full: true, // Controls the interface autohide feature.\r
+                               fadeIn: 200, // Milliseconds. The period of the fadeIn anim.\r
+                               fadeOut: 600, // Milliseconds. The period of the fadeOut anim.\r
+                               hold: 1000 // Milliseconds. The period of the pause before autohide beings.\r
+                       },\r
+                       loop: false,\r
+                       repeat: function(event) { // The default jPlayer repeat event handler\r
+                               if(event.jPlayer.options.loop) {\r
+                                       $(this).unbind(".jPlayerRepeat").bind($.jPlayer.event.ended + ".jPlayer.jPlayerRepeat", function() {\r
+                                               $(this).jPlayer("play");\r
+                                       });\r
+                               } else {\r
+                                       $(this).unbind(".jPlayerRepeat");\r
+                               }\r
+                       },\r
+                       nativeVideoControls: {\r
+                               // Works well on standard browsers.\r
+                               // Phone and tablet browsers can have problems with the controls disappearing.\r
+                       },\r
+                       noFullScreen: {\r
+                               msie: /msie [0-6]/,\r
+                               ipad: /ipad.*?os [0-4]/,\r
+                               iphone: /iphone/,\r
+                               ipod: /ipod/,\r
+                               android_pad: /android [0-3](?!.*?mobile)/,\r
+                               android_phone: /android.*?mobile/,\r
+                               blackberry: /blackberry/,\r
+                               windows_ce: /windows ce/,\r
+                               webos: /webos/\r
+                       },\r
+                       noVolume: {\r
+                               ipad: /ipad/,\r
+                               iphone: /iphone/,\r
+                               ipod: /ipod/,\r
+                               android_pad: /android(?!.*?mobile)/,\r
+                               android_phone: /android.*?mobile/,\r
+                               blackberry: /blackberry/,\r
+                               windows_ce: /windows ce/,\r
+                               webos: /webos/,\r
+                               playbook: /playbook/\r
+                       },\r
+                       verticalVolume: false, // Calculate volume from the bottom of the volume bar. Default is from the left. Also volume affects either width or height.\r
+                       // globalVolume: false, // Not implemented: Set to make volume changes affect all jPlayer instances\r
+                       // globalMute: false, // Not implemented: Set to make mute changes affect all jPlayer instances\r
+                       idPrefix: "jp", // Prefix for the ids of html elements created by jPlayer. For flash, this must not include characters: . - + * / \\r
+                       noConflict: "jQuery",\r
+                       emulateHtml: false, // Emulates the HTML5 Media element on the jPlayer element.\r
+                       errorAlerts: false,\r
+                       warningAlerts: false\r
+               },\r
+               optionsAudio: {\r
+                       size: {\r
+                               width: "0px",\r
+                               height: "0px",\r
+                               cssClass: ""\r
+                       },\r
+                       sizeFull: {\r
+                               width: "0px",\r
+                               height: "0px",\r
+                               cssClass: ""\r
+                       }\r
+               },\r
+               optionsVideo: {\r
+                       size: {\r
+                               width: "480px",\r
+                               height: "270px",\r
+                               cssClass: "jp-video-270p"\r
+                       },\r
+                       sizeFull: {\r
+                               width: "100%",\r
+                               height: "100%",\r
+                               cssClass: "jp-video-full"\r
+                       }\r
+               },\r
+               instances: {}, // Static Object\r
+               status: { // Instanced in _init()\r
+                       src: "",\r
+                       media: {},\r
+                       paused: true,\r
+                       format: {},\r
+                       formatType: "",\r
+                       waitForPlay: true, // Same as waitForLoad except in case where preloading.\r
+                       waitForLoad: true,\r
+                       srcSet: false,\r
+                       video: false, // True if playing a video\r
+                       seekPercent: 0,\r
+                       currentPercentRelative: 0,\r
+                       currentPercentAbsolute: 0,\r
+                       currentTime: 0,\r
+                       duration: 0,\r
+                       readyState: 0,\r
+                       networkState: 0,\r
+                       playbackRate: 1,\r
+                       ended: 0\r
+\r
+/*             Persistant status properties created dynamically at _init():\r
+                       width\r
+                       height\r
+                       cssClass\r
+                       nativeVideoControls\r
+                       noFullScreen\r
+                       noVolume\r
+*/\r
+               },\r
+\r
+               internal: { // Instanced in _init()\r
+                       ready: false\r
+                       // instance: undefined\r
+                       // domNode: undefined\r
+                       // htmlDlyCmdId: undefined\r
+                       // autohideId: undefined\r
+               },\r
+               solution: { // Static Object: Defines the solutions built in jPlayer.\r
+                       html: true,\r
+                       flash: true\r
+               },\r
+               // 'MPEG-4 support' : canPlayType('video/mp4; codecs="mp4v.20.8"')\r
+               format: { // Static Object\r
+                       mp3: {\r
+                               codec: 'audio/mpeg; codecs="mp3"',\r
+                               flashCanPlay: true,\r
+                               media: 'audio'\r
+                       },\r
+                       m4a: { // AAC / MP4\r
+                               codec: 'audio/mp4; codecs="mp4a.40.2"',\r
+                               flashCanPlay: true,\r
+                               media: 'audio'\r
+                       },\r
+                       oga: { // OGG\r
+                               codec: 'audio/ogg; codecs="vorbis"',\r
+                               flashCanPlay: false,\r
+                               media: 'audio'\r
+                       },\r
+                       wav: { // PCM\r
+                               codec: 'audio/wav; codecs="1"',\r
+                               flashCanPlay: false,\r
+                               media: 'audio'\r
+                       },\r
+                       webma: { // WEBM\r
+                               codec: 'audio/webm; codecs="vorbis"',\r
+                               flashCanPlay: false,\r
+                               media: 'audio'\r
+                       },\r
+                       fla: { // FLV / F4A\r
+                               codec: 'audio/x-flv',\r
+                               flashCanPlay: true,\r
+                               media: 'audio'\r
+                       },\r
+                       m4v: { // H.264 / MP4\r
+                               codec: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',\r
+                               flashCanPlay: true,\r
+                               media: 'video'\r
+                       },\r
+                       ogv: { // OGG\r
+                               codec: 'video/ogg; codecs="theora, vorbis"',\r
+                               flashCanPlay: false,\r
+                               media: 'video'\r
+                       },\r
+                       webmv: { // WEBM\r
+                               codec: 'video/webm; codecs="vorbis, vp8"',\r
+                               flashCanPlay: false,\r
+                               media: 'video'\r
+                       },\r
+                       flv: { // FLV / F4V\r
+                               codec: 'video/x-flv',\r
+                               flashCanPlay: true,\r
+                               media: 'video'\r
+                       }\r
+               },\r
+               _init: function() {\r
+                       var self = this;\r
+                       \r
+                       this.element.empty();\r
+                       \r
+                       this.status = $.extend({}, this.status); // Copy static to unique instance.\r
+                       this.internal = $.extend({}, this.internal); // Copy static to unique instance.\r
+\r
+                       this.internal.domNode = this.element.get(0);\r
+\r
+                       this.formats = []; // Array based on supplied string option. Order defines priority.\r
+                       this.solutions = []; // Array based on solution string option. Order defines priority.\r
+                       this.require = {}; // Which media types are required: video, audio.\r
+                       \r
+                       this.htmlElement = {}; // DOM elements created by jPlayer\r
+                       this.html = {}; // In _init()'s this.desired code and setmedia(): Accessed via this[solution], where solution from this.solutions array.\r
+                       this.html.audio = {};\r
+                       this.html.video = {};\r
+                       this.flash = {}; // In _init()'s this.desired code and setmedia(): Accessed via this[solution], where solution from this.solutions array.\r
+                       \r
+                       this.css = {};\r
+                       this.css.cs = {}; // Holds the css selector strings\r
+                       this.css.jq = {}; // Holds jQuery selectors. ie., $(css.cs.method)\r
+\r
+                       this.ancestorJq = []; // Holds jQuery selector of cssSelectorAncestor. Init would use $() instead of [], but it is only 1.4+\r
+\r
+                       this.options.volume = this._limitValue(this.options.volume, 0, 1); // Limit volume value's bounds.\r
+\r
+                       // Create the formats array, with prority based on the order of the supplied formats string\r
+                       $.each(this.options.supplied.toLowerCase().split(","), function(index1, value1) {\r
+                               var format = value1.replace(/^\s+|\s+$/g, ""); //trim\r
+                               if(self.format[format]) { // Check format is valid.\r
+                                       var dupFound = false;\r
+                                       $.each(self.formats, function(index2, value2) { // Check for duplicates\r
+                                               if(format === value2) {\r
+                                                       dupFound = true;\r
+                                                       return false;\r
+                                               }\r
+                                       });\r
+                                       if(!dupFound) {\r
+                                               self.formats.push(format);\r
+                                       }\r
+                               }\r
+                       });\r
+\r
+                       // Create the solutions array, with prority based on the order of the solution string\r
+                       $.each(this.options.solution.toLowerCase().split(","), function(index1, value1) {\r
+                               var solution = value1.replace(/^\s+|\s+$/g, ""); //trim\r
+                               if(self.solution[solution]) { // Check solution is valid.\r
+                                       var dupFound = false;\r
+                                       $.each(self.solutions, function(index2, value2) { // Check for duplicates\r
+                                               if(solution === value2) {\r
+                                                       dupFound = true;\r
+                                                       return false;\r
+                                               }\r
+                                       });\r
+                                       if(!dupFound) {\r
+                                               self.solutions.push(solution);\r
+                                       }\r
+                               }\r
+                       });\r
+\r
+                       this.internal.instance = "jp_" + this.count;\r
+                       this.instances[this.internal.instance] = this.element;\r
+\r
+                       // Check the jPlayer div has an id and create one if required. Important for Flash to know the unique id for comms.\r
+                       if(!this.element.attr("id")) {\r
+                               this.element.attr("id", this.options.idPrefix + "_jplayer_" + this.count);\r
+                       }\r
+\r
+                       this.internal.self = $.extend({}, {\r
+                               id: this.element.attr("id"),\r
+                               jq: this.element\r
+                       });\r
+                       this.internal.audio = $.extend({}, {\r
+                               id: this.options.idPrefix + "_audio_" + this.count,\r
+                               jq: undefined\r
+                       });\r
+                       this.internal.video = $.extend({}, {\r
+                               id: this.options.idPrefix + "_video_" + this.count,\r
+                               jq: undefined\r
+                       });\r
+                       this.internal.flash = $.extend({}, {\r
+                               id: this.options.idPrefix + "_flash_" + this.count,\r
+                               jq: undefined,\r
+                               swf: this.options.swfPath + (this.options.swfPath.toLowerCase().slice(-4) !== ".swf" ? (this.options.swfPath && this.options.swfPath.slice(-1) !== "/" ? "/" : "") + "Jplayer.swf" : "")\r
+                       });\r
+                       this.internal.poster = $.extend({}, {\r
+                               id: this.options.idPrefix + "_poster_" + this.count,\r
+                               jq: undefined\r
+                       });\r
+\r
+                       // Register listeners defined in the constructor\r
+                       $.each($.jPlayer.event, function(eventName,eventType) {\r
+                               if(self.options[eventName] !== undefined) {\r
+                                       self.element.bind(eventType + ".jPlayer", self.options[eventName]); // With .jPlayer namespace.\r
+                                       self.options[eventName] = undefined; // Destroy the handler pointer copy on the options. Reason, events can be added/removed in other ways so this could be obsolete and misleading.\r
+                               }\r
+                       });\r
+\r
+                       // Determine if we require solutions for audio, video or both media types.\r
+                       this.require.audio = false;\r
+                       this.require.video = false;\r
+                       $.each(this.formats, function(priority, format) {\r
+                               self.require[self.format[format].media] = true;\r
+                       });\r
+\r
+                       // Now required types are known, finish the options default settings.\r
+                       if(this.require.video) {\r
+                               this.options = $.extend(true, {},\r
+                                       this.optionsVideo,\r
+                                       this.options\r
+                               );\r
+                       } else {\r
+                               this.options = $.extend(true, {},\r
+                                       this.optionsAudio,\r
+                                       this.options\r
+                               );\r
+                       }\r
+                       this._setSize(); // update status and jPlayer element size\r
+\r
+                       // Determine the status for Blocklisted options.\r
+                       this.status.nativeVideoControls = this._uaBlocklist(this.options.nativeVideoControls);\r
+                       this.status.noFullScreen = this._uaBlocklist(this.options.noFullScreen);\r
+                       this.status.noVolume = this._uaBlocklist(this.options.noVolume);\r
+\r
+                       // The native controls are only for video and are disabled when audio is also used.\r
+                       this._restrictNativeVideoControls();\r
+\r
+                       // Create the poster image.\r
+                       this.htmlElement.poster = document.createElement('img');\r
+                       this.htmlElement.poster.id = this.internal.poster.id;\r
+                       this.htmlElement.poster.onload = function() { // Note that this did not work on Firefox 3.6: poster.addEventListener("onload", function() {}, false); Did not investigate x-browser.\r
+                               if(!self.status.video || self.status.waitForPlay) {\r
+                                       self.internal.poster.jq.show();\r
+                               }\r
+                       };\r
+                       this.element.append(this.htmlElement.poster);\r
+                       this.internal.poster.jq = $("#" + this.internal.poster.id);\r
+                       this.internal.poster.jq.css({'width': this.status.width, 'height': this.status.height});\r
+                       this.internal.poster.jq.hide();\r
+                       this.internal.poster.jq.bind("click.jPlayer", function() {\r
+                               self._trigger($.jPlayer.event.click);\r
+                       });\r
+                       \r
+                       // Generate the required media elements\r
+                       this.html.audio.available = false;\r
+                       if(this.require.audio) { // If a supplied format is audio\r
+                               this.htmlElement.audio = document.createElement('audio');\r
+                               this.htmlElement.audio.id = this.internal.audio.id;\r
+                               this.html.audio.available = !!this.htmlElement.audio.canPlayType && this._testCanPlayType(this.htmlElement.audio); // Test is for IE9 on Win Server 2008.\r
+                       }\r
+                       this.html.video.available = false;\r
+                       if(this.require.video) { // If a supplied format is video\r
+                               this.htmlElement.video = document.createElement('video');\r
+                               this.htmlElement.video.id = this.internal.video.id;\r
+                               this.html.video.available = !!this.htmlElement.video.canPlayType && this._testCanPlayType(this.htmlElement.video); // Test is for IE9 on Win Server 2008.\r
+                       }\r
+\r
+                       this.flash.available = this._checkForFlash(10);\r
+\r
+                       this.html.canPlay = {};\r
+                       this.flash.canPlay = {};\r
+                       $.each(this.formats, function(priority, format) {\r
+                               self.html.canPlay[format] = self.html[self.format[format].media].available && "" !== self.htmlElement[self.format[format].media].canPlayType(self.format[format].codec);\r
+                               self.flash.canPlay[format] = self.format[format].flashCanPlay && self.flash.available;\r
+                       });\r
+                       this.html.desired = false;\r
+                       this.flash.desired = false;\r
+                       $.each(this.solutions, function(solutionPriority, solution) {\r
+                               if(solutionPriority === 0) {\r
+                                       self[solution].desired = true;\r
+                               } else {\r
+                                       var audioCanPlay = false;\r
+                                       var videoCanPlay = false;\r
+                                       $.each(self.formats, function(formatPriority, format) {\r
+                                               if(self[self.solutions[0]].canPlay[format]) { // The other solution can play\r
+                                                       if(self.format[format].media === 'video') {\r
+                                                               videoCanPlay = true;\r
+                                                       } else {\r
+                                                               audioCanPlay = true;\r
+                                                       }\r
+                                               }\r
+                                       });\r
+                                       self[solution].desired = (self.require.audio && !audioCanPlay) || (self.require.video && !videoCanPlay);\r
+                               }\r
+                       });\r
+                       // This is what jPlayer will support, based on solution and supplied.\r
+                       this.html.support = {};\r
+                       this.flash.support = {};\r
+                       $.each(this.formats, function(priority, format) {\r
+                               self.html.support[format] = self.html.canPlay[format] && self.html.desired;\r
+                               self.flash.support[format] = self.flash.canPlay[format] && self.flash.desired;\r
+                       });\r
+                       // If jPlayer is supporting any format in a solution, then the solution is used.\r
+                       this.html.used = false;\r
+                       this.flash.used = false;\r
+                       $.each(this.solutions, function(solutionPriority, solution) {\r
+                               $.each(self.formats, function(formatPriority, format) {\r
+                                       if(self[solution].support[format]) {\r
+                                               self[solution].used = true;\r
+                                               return false;\r
+                                       }\r
+                               });\r
+                       });\r
+\r
+                       // Init solution active state and the event gates to false.\r
+                       this._resetActive();\r
+                       this._resetGate();\r
+\r
+                       // Set up the css selectors for the control and feedback entities.\r
+                       this._cssSelectorAncestor(this.options.cssSelectorAncestor);\r
+                       \r
+                       // If neither html nor flash are being used by this browser, then media playback is not possible. Trigger an error event.\r
+                       if(!(this.html.used || this.flash.used)) {\r
+                               this._error( {\r
+                                       type: $.jPlayer.error.NO_SOLUTION, \r
+                                       context: "{solution:'" + this.options.solution + "', supplied:'" + this.options.supplied + "'}",\r
+                                       message: $.jPlayer.errorMsg.NO_SOLUTION,\r
+                                       hint: $.jPlayer.errorHint.NO_SOLUTION\r
+                               });\r
+                               if(this.css.jq.noSolution.length) {\r
+                                       this.css.jq.noSolution.show();\r
+                               }\r
+                       } else {\r
+                               if(this.css.jq.noSolution.length) {\r
+                                       this.css.jq.noSolution.hide();\r
+                               }\r
+                       }\r
+\r
+                       // Add the flash solution if it is being used.\r
+                       if(this.flash.used) {\r
+                               var htmlObj,\r
+                               flashVars = 'jQuery=' + encodeURI(this.options.noConflict) + '&id=' + encodeURI(this.internal.self.id) + '&vol=' + this.options.volume + '&muted=' + this.options.muted;\r
+\r
+                               // Code influenced by SWFObject 2.2: http://code.google.com/p/swfobject/\r
+                               // Non IE browsers have an initial Flash size of 1 by 1 otherwise the wmode affected the Flash ready event. \r
+\r
+                               if($.browser.msie && Number($.browser.version) <= 8) {\r
+                                       var objStr = '<object id="' + this.internal.flash.id + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="0" height="0"></object>';\r
+\r
+                                       var paramStr = [\r
+                                               '<param name="movie" value="' + this.internal.flash.swf + '" />',\r
+                                               '<param name="FlashVars" value="' + flashVars + '" />',\r
+                                               '<param name="allowScriptAccess" value="always" />',\r
+                                               '<param name="bgcolor" value="' + this.options.backgroundColor + '" />',\r
+                                               '<param name="wmode" value="' + this.options.wmode + '" />'\r
+                                       ];\r
+\r
+                                       htmlObj = document.createElement(objStr);\r
+                                       for(var i=0; i < paramStr.length; i++) {\r
+                                               htmlObj.appendChild(document.createElement(paramStr[i]));\r
+                                       }\r
+                               } else {\r
+                                       var createParam = function(el, n, v) {\r
+                                               var p = document.createElement("param");\r
+                                               p.setAttribute("name", n);      \r
+                                               p.setAttribute("value", v);\r
+                                               el.appendChild(p);\r
+                                       };\r
+\r
+                                       htmlObj = document.createElement("object");\r
+                                       htmlObj.setAttribute("id", this.internal.flash.id);\r
+                                       htmlObj.setAttribute("data", this.internal.flash.swf);\r
+                                       htmlObj.setAttribute("type", "application/x-shockwave-flash");\r
+                                       htmlObj.setAttribute("width", "1"); // Non-zero\r
+                                       htmlObj.setAttribute("height", "1"); // Non-zero\r
+                                       createParam(htmlObj, "flashvars", flashVars);\r
+                                       createParam(htmlObj, "allowscriptaccess", "always");\r
+                                       createParam(htmlObj, "bgcolor", this.options.backgroundColor);\r
+                                       createParam(htmlObj, "wmode", this.options.wmode);\r
+                               }\r
+\r
+                               this.element.append(htmlObj);\r
+                               this.internal.flash.jq = $(htmlObj);\r
+                       }\r
+                       \r
+                       // Add the HTML solution if being used.\r
+                       if(this.html.used) {\r
+\r
+                               // The HTML Audio handlers\r
+                               if(this.html.audio.available) {\r
+                                       this._addHtmlEventListeners(this.htmlElement.audio, this.html.audio);\r
+                                       this.element.append(this.htmlElement.audio);\r
+                                       this.internal.audio.jq = $("#" + this.internal.audio.id);\r
+                               }\r
+\r
+                               // The HTML Video handlers\r
+                               if(this.html.video.available) {\r
+                                       this._addHtmlEventListeners(this.htmlElement.video, this.html.video);\r
+                                       this.element.append(this.htmlElement.video);\r
+                                       this.internal.video.jq = $("#" + this.internal.video.id);\r
+                                       if(this.status.nativeVideoControls) {\r
+                                               this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height});\r
+                                       } else {\r
+                                               this.internal.video.jq.css({'width':'0px', 'height':'0px'}); // Using size 0x0 since a .hide() causes issues in iOS\r
+                                       }\r
+                                       this.internal.video.jq.bind("click.jPlayer", function() {\r
+                                               self._trigger($.jPlayer.event.click);\r
+                                       });\r
+                               }\r
+                       }\r
+\r
+                       // Create the bridge that emulates the HTML Media element on the jPlayer DIV\r
+                       if( this.options.emulateHtml ) {\r
+                               this._emulateHtmlBridge();\r
+                       }\r
+\r
+                       if(this.html.used && !this.flash.used) { // If only HTML, then emulate flash ready() call after 100ms.\r
+                               setTimeout( function() {\r
+                                       self.internal.ready = true;\r
+                                       self.version.flash = "n/a";\r
+                                       self._trigger($.jPlayer.event.repeat); // Trigger the repeat event so its handler can initialize itself with the loop option.\r
+                                       self._trigger($.jPlayer.event.ready);\r
+                               }, 100);\r
+                       }\r
+\r
+                       // Initialize the interface components with the options.\r
+                       this._updateNativeVideoControls(); // Must do this first, otherwise there is a bizarre bug in iOS 4.3.2, where the native controls are not shown. Fails in iOS if called after _updateButtons() below. Works if called later in setMedia too, so it odd.\r
+                       this._updateInterface();\r
+                       this._updateButtons(false);\r
+                       this._updateAutohide();\r
+                       this._updateVolume(this.options.volume);\r
+                       this._updateMute(this.options.muted);\r
+                       if(this.css.jq.videoPlay.length) {\r
+                               this.css.jq.videoPlay.hide();\r
+                       }\r
+\r
+                       $.jPlayer.prototype.count++; // Change static variable via prototype.\r
+               },\r
+               destroy: function() {\r
+                       // MJP: The background change remains. Would need to store the original to restore it correctly.\r
+                       // MJP: The jPlayer element's size change remains.\r
+\r
+                       // Clear the media to reset the GUI and stop any downloads. Streams on some browsers had persited. (Chrome)\r
+                       this.clearMedia();\r
+                       // Remove the size/sizeFull cssClass from the cssSelectorAncestor\r
+                       this._removeUiClass();\r
+                       // Remove the times from the GUI\r
+                       if(this.css.jq.currentTime.length) {\r
+                               this.css.jq.currentTime.text("");\r
+                       }\r
+                       if(this.css.jq.duration.length) {\r
+                               this.css.jq.duration.text("");\r
+                       }\r
+                       // Remove any bindings from the interface controls.\r
+                       $.each(this.css.jq, function(fn, jq) {\r
+                               // Check selector is valid before trying to execute method.\r
+                               if(jq.length) {\r
+                                       jq.unbind(".jPlayer");\r
+                               }\r
+                       });\r
+                       // Remove the click handlers for $.jPlayer.event.click\r
+                       this.internal.poster.jq.unbind(".jPlayer");\r
+                       if(this.internal.video.jq) {\r
+                               this.internal.video.jq.unbind(".jPlayer");\r
+                       }\r
+                       // Destroy the HTML bridge.\r
+                       if(this.options.emulateHtml) {\r
+                               this._destroyHtmlBridge();\r
+                       }\r
+                       this.element.removeData("jPlayer"); // Remove jPlayer data\r
+                       this.element.unbind(".jPlayer"); // Remove all event handlers created by the jPlayer constructor\r
+                       this.element.empty(); // Remove the inserted child elements\r
+                       \r
+                       delete this.instances[this.internal.instance]; // Clear the instance on the static instance object\r
+               },\r
+               enable: function() { // Plan to implement\r
+                       // options.disabled = false\r
+               },\r
+               disable: function () { // Plan to implement\r
+                       // options.disabled = true\r
+               },\r
+               _testCanPlayType: function(elem) {\r
+                       // IE9 on Win Server 2008 did not implement canPlayType(), but it has the property.\r
+                       try {\r
+                               elem.canPlayType(this.format.mp3.codec); // The type is irrelevant.\r
+                               return true;\r
+                       } catch(err) {\r
+                               return false;\r
+                       }\r
+               },\r
+               _uaBlocklist: function(list) {\r
+                       // list : object with properties that are all regular expressions. Property names are irrelevant.\r
+                       // Returns true if the user agent is matched in list.\r
+                       var     ua = navigator.userAgent.toLowerCase(),\r
+                               block = false;\r
+\r
+                       $.each(list, function(p, re) {\r
+                               if(re && re.test(ua)) {\r
+                                       block = true;\r
+                                       return false; // exit $.each.\r
+                               }\r
+                       });\r
+                       return block;\r
+               },\r
+               _restrictNativeVideoControls: function() {\r
+                       // Fallback to noFullScreen when nativeVideoControls is true and audio media is being used. Affects when both media types are used.\r
+                       if(this.require.audio) {\r
+                               if(this.status.nativeVideoControls) {\r
+                                       this.status.nativeVideoControls = false;\r
+                                       this.status.noFullScreen = true;\r
+                               }\r
+                       }\r
+               },\r
+               _updateNativeVideoControls: function() {\r
+                       if(this.html.video.available && this.html.used) {\r
+                               // Turn the HTML Video controls on/off\r
+                               this.htmlElement.video.controls = this.status.nativeVideoControls;\r
+                               // Show/hide the jPlayer GUI.\r
+                               this._updateAutohide();\r
+                               // For when option changed. The poster image is not updated, as it is dealt with in setMedia(). Acceptable degradation since seriously doubt these options will change on the fly. Can again review later.\r
+                               if(this.status.nativeVideoControls && this.require.video) {\r
+                                       this.internal.poster.jq.hide();\r
+                                       this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height});\r
+                               } else if(this.status.waitForPlay && this.status.video) {\r
+                                       this.internal.poster.jq.show();\r
+                                       this.internal.video.jq.css({'width': '0px', 'height': '0px'});\r
+                               }\r
+                       }\r
+               },\r
+               _addHtmlEventListeners: function(mediaElement, entity) {\r
+                       var self = this;\r
+                       mediaElement.preload = this.options.preload;\r
+                       mediaElement.muted = this.options.muted;\r
+                       mediaElement.volume = this.options.volume;\r
+\r
+                       // Create the event listeners\r
+                       // Only want the active entity to affect jPlayer and bubble events.\r
+                       // Using entity.gate so that object is referenced and gate property always current\r
+                       \r
+                       mediaElement.addEventListener("progress", function() {\r
+                               if(entity.gate) {\r
+                                       self._getHtmlStatus(mediaElement);\r
+                                       self._updateInterface();\r
+                                       self._trigger($.jPlayer.event.progress);\r
+                               }\r
+                       }, false);\r
+                       mediaElement.addEventListener("timeupdate", function() {\r
+                               if(entity.gate) {\r
+                                       self._getHtmlStatus(mediaElement);\r
+                                       self._updateInterface();\r
+                                       self._trigger($.jPlayer.event.timeupdate);\r
+                               }\r
+                       }, false);\r
+                       mediaElement.addEventListener("durationchange", function() {\r
+                               if(entity.gate) {\r
+                                       self.status.duration = this.duration;\r
+                                       self._getHtmlStatus(mediaElement);\r
+                                       self._updateInterface();\r
+                                       self._trigger($.jPlayer.event.durationchange);\r
+                               }\r
+                       }, false);\r
+                       mediaElement.addEventListener("play", function() {\r
+                               if(entity.gate) {\r
+                                       self._updateButtons(true);\r
+                                       self._html_checkWaitForPlay(); // So the native controls update this variable and puts the hidden interface in the correct state. Affects toggling native controls.\r
+                                       self._trigger($.jPlayer.event.play);\r
+                               }\r
+                       }, false);\r
+                       mediaElement.addEventListener("playing", function() {\r
+                               if(entity.gate) {\r
+                                       self._updateButtons(true);\r
+                                       self._seeked();\r
+                                       self._trigger($.jPlayer.event.playing);\r
+                               }\r
+                       }, false);\r
+                       mediaElement.addEventListener("pause", function() {\r
+                               if(entity.gate) {\r
+                                       self._updateButtons(false);\r
+                                       self._trigger($.jPlayer.event.pause);\r
+                               }\r
+                       }, false);\r
+                       mediaElement.addEventListener("waiting", function() {\r
+                               if(entity.gate) {\r
+                                       self._seeking();\r
+                                       self._trigger($.jPlayer.event.waiting);\r
+                               }\r
+                       }, false);\r
+                       mediaElement.addEventListener("seeking", function() {\r
+                               if(entity.gate) {\r
+                                       self._seeking();\r
+                                       self._trigger($.jPlayer.event.seeking);\r
+                               }\r
+                       }, false);\r
+                       mediaElement.addEventListener("seeked", function() {\r
+                               if(entity.gate) {\r
+                                       self._seeked();\r
+                                       self._trigger($.jPlayer.event.seeked);\r
+                               }\r
+                       }, false);\r
+                       mediaElement.addEventListener("volumechange", function() {\r
+                               if(entity.gate) {\r
+                                       // Read the values back from the element as the Blackberry PlayBook shares the volume with the physical buttons master volume control.\r
+                                       // However, when tested 6th July 2011, those buttons do not generate an event. The physical play/pause button does though.\r
+                                       self.options.volume = mediaElement.volume;\r
+                                       self.options.muted = mediaElement.muted;\r
+                                       self._updateMute();\r
+                                       self._updateVolume();\r
+                                       self._trigger($.jPlayer.event.volumechange);\r
+                               }\r
+                       }, false);\r
+                       mediaElement.addEventListener("suspend", function() { // Seems to be the only way of capturing that the iOS4 browser did not actually play the media from the page code. ie., It needs a user gesture.\r
+                               if(entity.gate) {\r
+                                       self._seeked();\r
+                                       self._trigger($.jPlayer.event.suspend);\r
+                               }\r
+                       }, false);\r
+                       mediaElement.addEventListener("ended", function() {\r
+                               if(entity.gate) {\r
+                                       // Order of the next few commands are important. Change the time and then pause.\r
+                                       // Solves a bug in Firefox, where issuing pause 1st causes the media to play from the start. ie., The pause is ignored.\r
+                                       if(!$.jPlayer.browser.webkit) { // Chrome crashes if you do this in conjunction with a setMedia command in an ended event handler. ie., The playlist demo.\r
+                                               self.htmlElement.media.currentTime = 0; // Safari does not care about this command. ie., It works with or without this line. (Both Safari and Chrome are Webkit.)\r
+                                       }\r
+                                       self.htmlElement.media.pause(); // Pause otherwise a click on the progress bar will play from that point, when it shouldn't, since it stopped playback.\r
+                                       self._updateButtons(false);\r
+                                       self._getHtmlStatus(mediaElement, true); // With override true. Otherwise Chrome leaves progress at full.\r
+                                       self._updateInterface();\r
+                                       self._trigger($.jPlayer.event.ended);\r
+                               }\r
+                       }, false);\r
+                       mediaElement.addEventListener("error", function() {\r
+                               if(entity.gate) {\r
+                                       self._updateButtons(false);\r
+                                       self._seeked();\r
+                                       if(self.status.srcSet) { // Deals with case of clearMedia() causing an error event.\r
+                                               clearTimeout(self.internal.htmlDlyCmdId); // Clears any delayed commands used in the HTML solution.\r
+                                               self.status.waitForLoad = true; // Allows the load operation to try again.\r
+                                               self.status.waitForPlay = true; // Reset since a play was captured.\r
+                                               if(self.status.video && !self.status.nativeVideoControls) {\r
+                                                       self.internal.video.jq.css({'width':'0px', 'height':'0px'});\r
+                                               }\r
+                                               if(self._validString(self.status.media.poster) && !self.status.nativeVideoControls) {\r
+                                                       self.internal.poster.jq.show();\r
+                                               }\r
+                                               if(self.css.jq.videoPlay.length) {\r
+                                                       self.css.jq.videoPlay.show();\r
+                                               }\r
+                                               self._error( {\r
+                                                       type: $.jPlayer.error.URL,\r
+                                                       context: self.status.src, // this.src shows absolute urls. Want context to show the url given.\r
+                                                       message: $.jPlayer.errorMsg.URL,\r
+                                                       hint: $.jPlayer.errorHint.URL\r
+                                               });\r
+                                       }\r
+                               }\r
+                       }, false);\r
+                       // Create all the other event listeners that bubble up to a jPlayer event from html, without being used by jPlayer.\r
+                       $.each($.jPlayer.htmlEvent, function(i, eventType) {\r
+                               mediaElement.addEventListener(this, function() {\r
+                                       if(entity.gate) {\r
+                                               self._trigger($.jPlayer.event[eventType]);\r
+                                       }\r
+                               }, false);\r
+                       });\r
+               },\r
+               _getHtmlStatus: function(media, override) {\r
+                       var ct = 0, d = 0, cpa = 0, sp = 0, cpr = 0;\r
+\r
+                       if(media.duration) { // Fixes the duration bug in iOS, where the durationchange event occurs when media.duration is not always correct.\r
+                               this.status.duration = media.duration;\r
+                       }\r
+                       ct = media.currentTime;\r
+                       cpa = (this.status.duration > 0) ? 100 * ct / this.status.duration : 0;\r
+                       if((typeof media.seekable === "object") && (media.seekable.length > 0)) {\r
+                               sp = (this.status.duration > 0) ? 100 * media.seekable.end(media.seekable.length-1) / this.status.duration : 100;\r
+                               cpr = 100 * media.currentTime / media.seekable.end(media.seekable.length-1);\r
+                       } else {\r
+                               sp = 100;\r
+                               cpr = cpa;\r
+                       }\r
+                       \r
+                       if(override) {\r
+                               ct = 0;\r
+                               cpr = 0;\r
+                               cpa = 0;\r
+                       }\r
+\r
+                       this.status.seekPercent = sp;\r
+                       this.status.currentPercentRelative = cpr;\r
+                       this.status.currentPercentAbsolute = cpa;\r
+                       this.status.currentTime = ct;\r
+\r
+                       this.status.readyState = media.readyState;\r
+                       this.status.networkState = media.networkState;\r
+                       this.status.playbackRate = media.playbackRate;\r
+                       this.status.ended = media.ended;\r
+               },\r
+               _resetStatus: function() {\r
+                       this.status = $.extend({}, this.status, $.jPlayer.prototype.status); // Maintains the status properties that persist through a reset.\r
+               },\r
+               _trigger: function(eventType, error, warning) { // eventType always valid as called using $.jPlayer.event.eventType\r
+                       var event = $.Event(eventType);\r
+                       event.jPlayer = {};\r
+                       event.jPlayer.version = $.extend({}, this.version);\r
+                       event.jPlayer.options = $.extend(true, {}, this.options); // Deep copy\r
+                       event.jPlayer.status = $.extend(true, {}, this.status); // Deep copy\r
+                       event.jPlayer.html = $.extend(true, {}, this.html); // Deep copy\r
+                       event.jPlayer.flash = $.extend(true, {}, this.flash); // Deep copy\r
+                       if(error) {\r
+                               event.jPlayer.error = $.extend({}, error);\r
+                       }\r
+                       if(warning) {\r
+                               event.jPlayer.warning = $.extend({}, warning);\r
+                       }\r
+                       this.element.trigger(event);\r
+               },\r
+               jPlayerFlashEvent: function(eventType, status) { // Called from Flash\r
+                       if(eventType === $.jPlayer.event.ready) {\r
+                               if(!this.internal.ready) {\r
+                                       this.internal.ready = true;\r
+                                       this.internal.flash.jq.css({'width':'0px', 'height':'0px'}); // Once Flash generates the ready event, minimise to zero as it is not affected by wmode anymore.\r
+\r
+                                       this.version.flash = status.version;\r
+                                       if(this.version.needFlash !== this.version.flash) {\r
+                                               this._error( {\r
+                                                       type: $.jPlayer.error.VERSION,\r
+                                                       context: this.version.flash,\r
+                                                       message: $.jPlayer.errorMsg.VERSION + this.version.flash,\r
+                                                       hint: $.jPlayer.errorHint.VERSION\r
+                                               });\r
+                                       }\r
+                                       this._trigger($.jPlayer.event.repeat); // Trigger the repeat event so its handler can initialize itself with the loop option.\r
+                                       this._trigger(eventType);\r
+                               } else {\r
+                                       // This condition occurs if the Flash is hidden and then shown again.\r
+                                       // Firefox also reloads the Flash if the CSS position changes. position:fixed is used for full screen.\r
+\r
+                                       // Only do this if the Flash is the solution being used at the moment. Affects Media players where both solution may be being used.\r
+                                       if(this.flash.gate) {\r
+\r
+                                               // Send the current status to the Flash now that it is ready (available) again.\r
+                                               if(this.status.srcSet) {\r
+\r
+                                                       // Need to read original status before issuing the setMedia command.\r
+                                                       var     currentTime = this.status.currentTime,\r
+                                                               paused = this.status.paused; \r
+\r
+                                                       this.setMedia(this.status.media);\r
+                                                       if(currentTime > 0) {\r
+                                                               if(paused) {\r
+                                                                       this.pause(currentTime);\r
+                                                               } else {\r
+                                                                       this.play(currentTime);\r
+                                                               }\r
+                                                       }\r
+                                               }\r
+                                               this._trigger($.jPlayer.event.flashreset);\r
+                                       }\r
+                               }\r
+                       }\r
+                       if(this.flash.gate) {\r
+                               switch(eventType) {\r
+                                       case $.jPlayer.event.progress:\r
+                                               this._getFlashStatus(status);\r
+                                               this._updateInterface();\r
+                                               this._trigger(eventType);\r
+                                               break;\r
+                                       case $.jPlayer.event.timeupdate:\r
+                                               this._getFlashStatus(status);\r
+                                               this._updateInterface();\r
+                                               this._trigger(eventType);\r
+                                               break;\r
+                                       case $.jPlayer.event.play:\r
+                                               this._seeked();\r
+                                               this._updateButtons(true);\r
+                                               this._trigger(eventType);\r
+                                               break;\r
+                                       case $.jPlayer.event.pause:\r
+                                               this._updateButtons(false);\r
+                                               this._trigger(eventType);\r
+                                               break;\r
+                                       case $.jPlayer.event.ended:\r
+                                               this._updateButtons(false);\r
+                                               this._trigger(eventType);\r
+                                               break;\r
+                                       case $.jPlayer.event.click:\r
+                                               this._trigger(eventType); // This could be dealt with by the default\r
+                                               break;\r
+                                       case $.jPlayer.event.error:\r
+                                               this.status.waitForLoad = true; // Allows the load operation to try again.\r
+                                               this.status.waitForPlay = true; // Reset since a play was captured.\r
+                                               if(this.status.video) {\r
+                                                       this.internal.flash.jq.css({'width':'0px', 'height':'0px'});\r
+                                               }\r
+                                               if(this._validString(this.status.media.poster)) {\r
+                                                       this.internal.poster.jq.show();\r
+                                               }\r
+                                               if(this.css.jq.videoPlay.length && this.status.video) {\r
+                                                       this.css.jq.videoPlay.show();\r
+                                               }\r
+                                               if(this.status.video) { // Set up for another try. Execute before error event.\r
+                                                       this._flash_setVideo(this.status.media);\r
+                                               } else {\r
+                                                       this._flash_setAudio(this.status.media);\r
+                                               }\r
+                                               this._updateButtons(false);\r
+                                               this._error( {\r
+                                                       type: $.jPlayer.error.URL,\r
+                                                       context:status.src,\r
+                                                       message: $.jPlayer.errorMsg.URL,\r
+                                                       hint: $.jPlayer.errorHint.URL\r
+                                               });\r
+                                               break;\r
+                                       case $.jPlayer.event.seeking:\r
+                                               this._seeking();\r
+                                               this._trigger(eventType);\r
+                                               break;\r
+                                       case $.jPlayer.event.seeked:\r
+                                               this._seeked();\r
+                                               this._trigger(eventType);\r
+                                               break;\r
+                                       case $.jPlayer.event.ready:\r
+                                               // The ready event is handled outside the switch statement.\r
+                                               // Captured here otherwise 2 ready events would be generated if the ready event handler used setMedia.\r
+                                               break;\r
+                                       default:\r
+                                               this._trigger(eventType);\r
+                               }\r
+                       }\r
+                       return false;\r
+               },\r
+               _getFlashStatus: function(status) {\r
+                       this.status.seekPercent = status.seekPercent;\r
+                       this.status.currentPercentRelative = status.currentPercentRelative;\r
+                       this.status.currentPercentAbsolute = status.currentPercentAbsolute;\r
+                       this.status.currentTime = status.currentTime;\r
+                       this.status.duration = status.duration;\r
+\r
+                       // The Flash does not generate this information in this release\r
+                       this.status.readyState = 4; // status.readyState;\r
+                       this.status.networkState = 0; // status.networkState;\r
+                       this.status.playbackRate = 1; // status.playbackRate;\r
+                       this.status.ended = false; // status.ended;\r
+               },\r
+               _updateButtons: function(playing) {\r
+                       if(playing !== undefined) {\r
+                               this.status.paused = !playing;\r
+                               if(this.css.jq.play.length && this.css.jq.pause.length) {\r
+                                       if(playing) {\r
+                                               this.css.jq.play.hide();\r
+                                               this.css.jq.pause.show();\r
+                                       } else {\r
+                                               this.css.jq.play.show();\r
+                                               this.css.jq.pause.hide();\r
+                                       }\r
+                               }\r
+                       }\r
+                       if(this.css.jq.restoreScreen.length && this.css.jq.fullScreen.length) {\r
+                               if(this.status.noFullScreen) {\r
+                                       this.css.jq.fullScreen.hide();\r
+                                       this.css.jq.restoreScreen.hide();\r
+                               } else if(this.options.fullScreen) {\r
+                                       this.css.jq.fullScreen.hide();\r
+                                       this.css.jq.restoreScreen.show();\r
+                               } else {\r
+                                       this.css.jq.fullScreen.show();\r
+                                       this.css.jq.restoreScreen.hide();\r
+                               }\r
+                       }\r
+                       if(this.css.jq.repeat.length && this.css.jq.repeatOff.length) {\r
+                               if(this.options.loop) {\r
+                                       this.css.jq.repeat.hide();\r
+                                       this.css.jq.repeatOff.show();\r
+                               } else {\r
+                                       this.css.jq.repeat.show();\r
+                                       this.css.jq.repeatOff.hide();\r
+                               }\r
+                       }\r
+               },\r
+               _updateInterface: function() {\r
+                       if(this.css.jq.seekBar.length) {\r
+                               this.css.jq.seekBar.width(this.status.seekPercent+"%");\r
+                       }\r
+                       if(this.css.jq.playBar.length) {\r
+                               this.css.jq.playBar.width(this.status.currentPercentRelative+"%");\r
+                       }\r
+                       if(this.css.jq.currentTime.length) {\r
+                               this.css.jq.currentTime.text($.jPlayer.convertTime(this.status.currentTime));\r
+                       }\r
+                       if(this.css.jq.duration.length) {\r
+                               this.css.jq.duration.text($.jPlayer.convertTime(this.status.duration));\r
+                       }\r
+               },\r
+               _seeking: function() {\r
+                       if(this.css.jq.seekBar.length) {\r
+                               this.css.jq.seekBar.addClass("jp-seeking-bg");\r
+                       }\r
+               },\r
+               _seeked: function() {\r
+                       if(this.css.jq.seekBar.length) {\r
+                               this.css.jq.seekBar.removeClass("jp-seeking-bg");\r
+                       }\r
+               },\r
+               _resetGate: function() {\r
+                       this.html.audio.gate = false;\r
+                       this.html.video.gate = false;\r
+                       this.flash.gate = false;\r
+               },\r
+               _resetActive: function() {\r
+                       this.html.active = false;\r
+                       this.flash.active = false;\r
+               },\r
+               setMedia: function(media) {\r
+               \r
+                       /*      media[format] = String: URL of format. Must contain all of the supplied option's video or audio formats.\r
+                        *      media.poster = String: Video poster URL.\r
+                        *      media.subtitles = String: * NOT IMPLEMENTED * URL of subtitles SRT file\r
+                        *      media.chapters = String: * NOT IMPLEMENTED * URL of chapters SRT file\r
+                        *      media.stream = Boolean: * NOT IMPLEMENTED * Designating actual media streams. ie., "false/undefined" for files. Plan to refresh the flash every so often.\r
+                        */\r
+\r
+                       var     self = this,\r
+                               supported = false,\r
+                               posterChanged = this.status.media.poster !== media.poster; // Compare before reset. Important for OSX Safari as this.htmlElement.poster.src is absolute, even if original poster URL was relative.\r
+\r
+                       this._resetMedia();\r
+                       this._resetGate();\r
+                       this._resetActive();\r
+\r
+                       $.each(this.formats, function(formatPriority, format) {\r
+                               var isVideo = self.format[format].media === 'video';\r
+                               $.each(self.solutions, function(solutionPriority, solution) {\r
+                                       if(self[solution].support[format] && self._validString(media[format])) { // Format supported in solution and url given for format.\r
+                                               var isHtml = solution === 'html';\r
+\r
+                                               if(isVideo) {\r
+                                                       if(isHtml) {\r
+                                                               self.html.video.gate = true;\r
+                                                               self._html_setVideo(media);\r
+                                                               self.html.active = true;\r
+                                                       } else {\r
+                                                               self.flash.gate = true;\r
+                                                               self._flash_setVideo(media);\r
+                                                               self.flash.active = true;\r
+                                                       }\r
+                                                       if(self.css.jq.videoPlay.length) {\r
+                                                               self.css.jq.videoPlay.show();\r
+                                                       }\r
+                                                       self.status.video = true;\r
+                                               } else {\r
+                                                       if(isHtml) {\r
+                                                               self.html.audio.gate = true;\r
+                                                               self._html_setAudio(media);\r
+                                                               self.html.active = true;\r
+                                                       } else {\r
+                                                               self.flash.gate = true;\r
+                                                               self._flash_setAudio(media);\r
+                                                               self.flash.active = true;\r
+                                                       }\r
+                                                       if(self.css.jq.videoPlay.length) {\r
+                                                               self.css.jq.videoPlay.hide();\r
+                                                       }\r
+                                                       self.status.video = false;\r
+                                               }\r
+                                               \r
+                                               supported = true;\r
+                                               return false; // Exit $.each\r
+                                       }\r
+                               });\r
+                               if(supported) {\r
+                                       return false; // Exit $.each\r
+                               }\r
+                       });\r
+\r
+                       if(supported) {\r
+                               if(!(this.status.nativeVideoControls && this.html.video.gate)) {\r
+                                       // Set poster IMG if native video controls are not being used\r
+                                       // Note: With IE the IMG onload event occurs immediately when cached.\r
+                                       // Note: Poster hidden by default in _resetMedia()\r
+                                       if(this._validString(media.poster)) {\r
+                                               if(posterChanged) { // Since some browsers do not generate img onload event.\r
+                                                       this.htmlElement.poster.src = media.poster;\r
+                                               } else {\r
+                                                       this.internal.poster.jq.show();\r
+                                               }\r
+                                       }\r
+                               }\r
+                               this.status.srcSet = true;\r
+                               this.status.media = $.extend({}, media);\r
+                               this._updateButtons(false);\r
+                               this._updateInterface();\r
+                       } else { // jPlayer cannot support any formats provided in this browser\r
+                               // Send an error event\r
+                               this._error( {\r
+                                       type: $.jPlayer.error.NO_SUPPORT,\r
+                                       context: "{supplied:'" + this.options.supplied + "'}",\r
+                                       message: $.jPlayer.errorMsg.NO_SUPPORT,\r
+                                       hint: $.jPlayer.errorHint.NO_SUPPORT\r
+                               });\r
+                       }\r
+               },\r
+               _resetMedia: function() {\r
+                       this._resetStatus();\r
+                       this._updateButtons(false);\r
+                       this._updateInterface();\r
+                       this._seeked();\r
+                       this.internal.poster.jq.hide();\r
+\r
+                       clearTimeout(this.internal.htmlDlyCmdId);\r
+\r
+                       if(this.html.active) {\r
+                               this._html_resetMedia();\r
+                       } else if(this.flash.active) {\r
+                               this._flash_resetMedia();\r
+                       }\r
+               },\r
+               clearMedia: function() {\r
+                       this._resetMedia();\r
+\r
+                       if(this.html.active) {\r
+                               this._html_clearMedia();\r
+                       } else if(this.flash.active) {\r
+                               this._flash_clearMedia();\r
+                       }\r
+\r
+                       this._resetGate();\r
+                       this._resetActive();\r
+               },\r
+               load: function() {\r
+                       if(this.status.srcSet) {\r
+                               if(this.html.active) {\r
+                                       this._html_load();\r
+                               } else if(this.flash.active) {\r
+                                       this._flash_load();\r
+                               }\r
+                       } else {\r
+                               this._urlNotSetError("load");\r
+                       }\r
+               },\r
+               play: function(time) {\r
+                       time = (typeof time === "number") ? time : NaN; // Remove jQuery event from click handler\r
+                       if(this.status.srcSet) {\r
+                               if(this.html.active) {\r
+                                       this._html_play(time);\r
+                               } else if(this.flash.active) {\r
+                                       this._flash_play(time);\r
+                               }\r
+                       } else {\r
+                               this._urlNotSetError("play");\r
+                       }\r
+               },\r
+               videoPlay: function(e) { // Handles clicks on the play button over the video poster\r
+                       this.play();\r
+               },\r
+               pause: function(time) {\r
+                       time = (typeof time === "number") ? time : NaN; // Remove jQuery event from click handler\r
+                       if(this.status.srcSet) {\r
+                               if(this.html.active) {\r
+                                       this._html_pause(time);\r
+                               } else if(this.flash.active) {\r
+                                       this._flash_pause(time);\r
+                               }\r
+                       } else {\r
+                               this._urlNotSetError("pause");\r
+                       }\r
+               },\r
+               pauseOthers: function() {\r
+                       var self = this;\r
+                       $.each(this.instances, function(i, element) {\r
+                               if(self.element !== element) { // Do not this instance.\r
+                                       if(element.data("jPlayer").status.srcSet) { // Check that media is set otherwise would cause error event.\r
+                                               element.jPlayer("pause");\r
+                                       }\r
+                               }\r
+                       });\r
+               },\r
+               stop: function() {\r
+                       if(this.status.srcSet) {\r
+                               if(this.html.active) {\r
+                                       this._html_pause(0);\r
+                               } else if(this.flash.active) {\r
+                                       this._flash_pause(0);\r
+                               }\r
+                       } else {\r
+                               this._urlNotSetError("stop");\r
+                       }\r
+               },\r
+               playHead: function(p) {\r
+                       p = this._limitValue(p, 0, 100);\r
+                       if(this.status.srcSet) {\r
+                               if(this.html.active) {\r
+                                       this._html_playHead(p);\r
+                               } else if(this.flash.active) {\r
+                                       this._flash_playHead(p);\r
+                               }\r
+                       } else {\r
+                               this._urlNotSetError("playHead");\r
+                       }\r
+               },\r
+               _muted: function(muted) {\r
+                       this.options.muted = muted;\r
+                       if(this.html.used) {\r
+                               this._html_mute(muted);\r
+                       }\r
+                       if(this.flash.used) {\r
+                               this._flash_mute(muted);\r
+                       }\r
+\r
+                       // The HTML solution generates this event from the media element itself.\r
+                       if(!this.html.video.gate && !this.html.audio.gate) {\r
+                               this._updateMute(muted);\r
+                               this._updateVolume(this.options.volume);\r
+                               this._trigger($.jPlayer.event.volumechange);\r
+                       }\r
+               },\r
+               mute: function(mute) { // mute is either: undefined (true), an event object (true) or a boolean (muted).\r
+                       mute = mute === undefined ? true : !!mute;\r
+                       this._muted(mute);\r
+               },\r
+               unmute: function(unmute) { // unmute is either: undefined (true), an event object (true) or a boolean (!muted).\r
+                       unmute = unmute === undefined ? true : !!unmute;\r
+                       this._muted(!unmute);\r
+               },\r
+               _updateMute: function(mute) {\r
+                       if(mute === undefined) {\r
+                               mute = this.options.muted;\r
+                       }\r
+                       if(this.css.jq.mute.length && this.css.jq.unmute.length) {\r
+                               if(this.status.noVolume) {\r
+                                       this.css.jq.mute.hide();\r
+                                       this.css.jq.unmute.hide();\r
+                               } else if(mute) {\r
+                                       this.css.jq.mute.hide();\r
+                                       this.css.jq.unmute.show();\r
+                               } else {\r
+                                       this.css.jq.mute.show();\r
+                                       this.css.jq.unmute.hide();\r
+                               }\r
+                       }\r
+               },\r
+               volume: function(v) {\r
+                       v = this._limitValue(v, 0, 1);\r
+                       this.options.volume = v;\r
+\r
+                       if(this.html.used) {\r
+                               this._html_volume(v);\r
+                       }\r
+                       if(this.flash.used) {\r
+                               this._flash_volume(v);\r
+                       }\r
+\r
+                       // The HTML solution generates this event from the media element itself.\r
+                       if(!this.html.video.gate && !this.html.audio.gate) {\r
+                               this._updateVolume(v);\r
+                               this._trigger($.jPlayer.event.volumechange);\r
+                       }\r
+               },\r
+               volumeBar: function(e) { // Handles clicks on the volumeBar\r
+                       if(this.css.jq.volumeBar.length) {\r
+                               var     offset = this.css.jq.volumeBar.offset(),\r
+                                       x = e.pageX - offset.left,\r
+                                       w = this.css.jq.volumeBar.width(),\r
+                                       y = this.css.jq.volumeBar.height() - e.pageY + offset.top,\r
+                                       h = this.css.jq.volumeBar.height();\r
+\r
+                               if(this.options.verticalVolume) {\r
+                                       this.volume(y/h);\r
+                               } else {\r
+                                       this.volume(x/w);\r
+                               }\r
+                       }\r
+                       if(this.options.muted) {\r
+                               this._muted(false);\r
+                       }\r
+               },\r
+               volumeBarValue: function(e) { // Handles clicks on the volumeBarValue\r
+                       this.volumeBar(e);\r
+               },\r
+               _updateVolume: function(v) {\r
+                       if(v === undefined) {\r
+                               v = this.options.volume;\r
+                       }\r
+                       v = this.options.muted ? 0 : v;\r
+\r
+                       if(this.status.noVolume) {\r
+                               if(this.css.jq.volumeBar.length) {\r
+                                       this.css.jq.volumeBar.hide();\r
+                               }\r
+                               if(this.css.jq.volumeBarValue.length) {\r
+                                       this.css.jq.volumeBarValue.hide();\r
+                               }\r
+                               if(this.css.jq.volumeMax.length) {\r
+                                       this.css.jq.volumeMax.hide();\r
+                               }\r
+                       } else {\r
+                               if(this.css.jq.volumeBar.length) {\r
+                                       this.css.jq.volumeBar.show();\r
+                               }\r
+                               if(this.css.jq.volumeBarValue.length) {\r
+                                       this.css.jq.volumeBarValue.show();\r
+                                       this.css.jq.volumeBarValue[this.options.verticalVolume ? "height" : "width"]((v*100)+"%");\r
+                               }\r
+                               if(this.css.jq.volumeMax.length) {\r
+                                       this.css.jq.volumeMax.show();\r
+                               }\r
+                       }\r
+               },\r
+               volumeMax: function() { // Handles clicks on the volume max\r
+                       this.volume(1);\r
+                       if(this.options.muted) {\r
+                               this._muted(false);\r
+                       }\r
+               },\r
+               _cssSelectorAncestor: function(ancestor) {\r
+                       var self = this;\r
+                       this.options.cssSelectorAncestor = ancestor;\r
+                       this._removeUiClass();\r
+                       this.ancestorJq = ancestor ? $(ancestor) : []; // Would use $() instead of [], but it is only 1.4+\r
+                       if(ancestor && this.ancestorJq.length !== 1) { // So empty strings do not generate the warning.\r
+                               this._warning( {\r
+                                       type: $.jPlayer.warning.CSS_SELECTOR_COUNT,\r
+                                       context: ancestor,\r
+                                       message: $.jPlayer.warningMsg.CSS_SELECTOR_COUNT + this.ancestorJq.length + " found for cssSelectorAncestor.",\r
+                                       hint: $.jPlayer.warningHint.CSS_SELECTOR_COUNT\r
+                               });\r
+                       }\r
+                       this._addUiClass();\r
+                       $.each(this.options.cssSelector, function(fn, cssSel) {\r
+                               self._cssSelector(fn, cssSel);\r
+                       });\r
+               },\r
+               _cssSelector: function(fn, cssSel) {\r
+                       var self = this;\r
+                       if(typeof cssSel === 'string') {\r
+                               if($.jPlayer.prototype.options.cssSelector[fn]) {\r
+                                       if(this.css.jq[fn] && this.css.jq[fn].length) {\r
+                                               this.css.jq[fn].unbind(".jPlayer");\r
+                                       }\r
+                                       this.options.cssSelector[fn] = cssSel;\r
+                                       this.css.cs[fn] = this.options.cssSelectorAncestor + " " + cssSel;\r
+\r
+                                       if(cssSel) { // Checks for empty string\r
+                                               this.css.jq[fn] = $(this.css.cs[fn]);\r
+                                       } else {\r
+                                               this.css.jq[fn] = []; // To comply with the css.jq[fn].length check before its use. As of jQuery 1.4 could have used $() for an empty set. \r
+                                       }\r
+\r
+                                       if(this.css.jq[fn].length) {\r
+                                               var handler = function(e) {\r
+                                                       self[fn](e);\r
+                                                       $(this).blur();\r
+                                                       return false;\r
+                                               };\r
+                                               this.css.jq[fn].bind("click.jPlayer", handler); // Using jPlayer namespace\r
+                                       }\r
+\r
+                                       if(cssSel && this.css.jq[fn].length !== 1) { // So empty strings do not generate the warning. ie., they just remove the old one.\r
+                                               this._warning( {\r
+                                                       type: $.jPlayer.warning.CSS_SELECTOR_COUNT,\r
+                                                       context: this.css.cs[fn],\r
+                                                       message: $.jPlayer.warningMsg.CSS_SELECTOR_COUNT + this.css.jq[fn].length + " found for " + fn + " method.",\r
+                                                       hint: $.jPlayer.warningHint.CSS_SELECTOR_COUNT\r
+                                               });\r
+                                       }\r
+                               } else {\r
+                                       this._warning( {\r
+                                               type: $.jPlayer.warning.CSS_SELECTOR_METHOD,\r
+                                               context: fn,\r
+                                               message: $.jPlayer.warningMsg.CSS_SELECTOR_METHOD,\r
+                                               hint: $.jPlayer.warningHint.CSS_SELECTOR_METHOD\r
+                                       });\r
+                               }\r
+                       } else {\r
+                               this._warning( {\r
+                                       type: $.jPlayer.warning.CSS_SELECTOR_STRING,\r
+                                       context: cssSel,\r
+                                       message: $.jPlayer.warningMsg.CSS_SELECTOR_STRING,\r
+                                       hint: $.jPlayer.warningHint.CSS_SELECTOR_STRING\r
+                               });\r
+                       }\r
+               },\r
+               seekBar: function(e) { // Handles clicks on the seekBar\r
+                       if(this.css.jq.seekBar) {\r
+                               var offset = this.css.jq.seekBar.offset();\r
+                               var x = e.pageX - offset.left;\r
+                               var w = this.css.jq.seekBar.width();\r
+                               var p = 100*x/w;\r
+                               this.playHead(p);\r
+                       }\r
+               },\r
+               playBar: function(e) { // Handles clicks on the playBar\r
+                       this.seekBar(e);\r
+               },\r
+               repeat: function() { // Handle clicks on the repeat button\r
+                       this._loop(true);\r
+               },\r
+               repeatOff: function() { // Handle clicks on the repeatOff button\r
+                       this._loop(false);\r
+               },\r
+               _loop: function(loop) {\r
+                       if(this.options.loop !== loop) {\r
+                               this.options.loop = loop;\r
+                               this._updateButtons();\r
+                               this._trigger($.jPlayer.event.repeat);\r
+                       }\r
+               },\r
+\r
+               // Plan to review the cssSelector method to cope with missing associated functions accordingly.\r
+\r
+               currentTime: function(e) { // Handles clicks on the text\r
+                       // Added to avoid errors using cssSelector system for the text\r
+               },\r
+               duration: function(e) { // Handles clicks on the text\r
+                       // Added to avoid errors using cssSelector system for the text\r
+               },\r
+               gui: function(e) { // Handles clicks on the gui\r
+                       // Added to avoid errors using cssSelector system for the gui\r
+               },\r
+               noSolution: function(e) { // Handles clicks on the error message\r
+                       // Added to avoid errors using cssSelector system for no-solution\r
+               },\r
+\r
+               // Options code adapted from ui.widget.js (1.8.7).  Made changes so the key can use dot notation. To match previous getData solution in jPlayer 1.\r
+               option: function(key, value) {\r
+                       var options = key;\r
+\r
+                        // Enables use: options().  Returns a copy of options object\r
+                       if ( arguments.length === 0 ) {\r
+                               return $.extend( true, {}, this.options );\r
+                       }\r
+\r
+                       if(typeof key === "string") {\r
+                               var keys = key.split(".");\r
+\r
+                                // Enables use: options("someOption")  Returns a copy of the option. Supports dot notation.\r
+                               if(value === undefined) {\r
+\r
+                                       var opt = $.extend(true, {}, this.options);\r
+                                       for(var i = 0; i < keys.length; i++) {\r
+                                               if(opt[keys[i]] !== undefined) {\r
+                                                       opt = opt[keys[i]];\r
+                                               } else {\r
+                                                       this._warning( {\r
+                                                               type: $.jPlayer.warning.OPTION_KEY,\r
+                                                               context: key,\r
+                                                               message: $.jPlayer.warningMsg.OPTION_KEY,\r
+                                                               hint: $.jPlayer.warningHint.OPTION_KEY\r
+                                                       });\r
+                                                       return undefined;\r
+                                               }\r
+                                       }\r
+                                       return opt;\r
+                               }\r
+\r
+                                // Enables use: options("someOptionObject", someObject}).  Creates: {someOptionObject:someObject}\r
+                                // Enables use: options("someOption", someValue).  Creates: {someOption:someValue}\r
+                                // Enables use: options("someOptionObject.someOption", someValue).  Creates: {someOptionObject:{someOption:someValue}}\r
+\r
+                               options = {};\r
+                               var opts = options;\r
+\r
+                               for(var j = 0; j < keys.length; j++) {\r
+                                       if(j < keys.length - 1) {\r
+                                               opts[keys[j]] = {};\r
+                                               opts = opts[keys[j]];\r
+                                       } else {\r
+                                               opts[keys[j]] = value;\r
+                                       }\r
+                               }\r
+                       }\r
+\r
+                        // Otherwise enables use: options(optionObject).  Uses original object (the key)\r
+\r
+                       this._setOptions(options);\r
+\r
+                       return this;\r
+               },\r
+               _setOptions: function(options) {\r
+                       var self = this;\r
+                       $.each(options, function(key, value) { // This supports the 2 level depth that the options of jPlayer has. Would review if we ever need more depth.\r
+                               self._setOption(key, value);\r
+                       });\r
+\r
+                       return this;\r
+               },\r
+               _setOption: function(key, value) {\r
+                       var self = this;\r
+\r
+                       // The ability to set options is limited at this time.\r
+\r
+                       switch(key) {\r
+                               case "volume" :\r
+                                       this.volume(value);\r
+                                       break;\r
+                               case "muted" :\r
+                                       this._muted(value);\r
+                                       break;\r
+                               case "cssSelectorAncestor" :\r
+                                       this._cssSelectorAncestor(value); // Set and refresh all associations for the new ancestor.\r
+                                       break;\r
+                               case "cssSelector" :\r
+                                       $.each(value, function(fn, cssSel) {\r
+                                               self._cssSelector(fn, cssSel); // NB: The option is set inside this function, after further validity checks.\r
+                                       });\r
+                                       break;\r
+                               case "fullScreen" :\r
+                                       if(this.options[key] !== value) { // if changed\r
+                                               this._removeUiClass();\r
+                                               this.options[key] = value;\r
+                                               this._refreshSize();\r
+                                       }\r
+                                       break;\r
+                               case "size" :\r
+                                       if(!this.options.fullScreen && this.options[key].cssClass !== value.cssClass) {\r
+                                               this._removeUiClass();\r
+                                       }\r
+                                       this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.\r
+                                       this._refreshSize();\r
+                                       break;\r
+                               case "sizeFull" :\r
+                                       if(this.options.fullScreen && this.options[key].cssClass !== value.cssClass) {\r
+                                               this._removeUiClass();\r
+                                       }\r
+                                       this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.\r
+                                       this._refreshSize();\r
+                                       break;\r
+                               case "autohide" :\r
+                                       this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.\r
+                                       this._updateAutohide();\r
+                                       break;\r
+                               case "loop" :\r
+                                       this._loop(value);\r
+                                       break;\r
+                               case "nativeVideoControls" :\r
+                                       this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.\r
+                                       this.status.nativeVideoControls = this._uaBlocklist(this.options.nativeVideoControls);\r
+                                       this._restrictNativeVideoControls();\r
+                                       this._updateNativeVideoControls();\r
+                                       break;\r
+                               case "noFullScreen" :\r
+                                       this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.\r
+                                       this.status.nativeVideoControls = this._uaBlocklist(this.options.nativeVideoControls); // Need to check again as noFullScreen can depend on this flag and the restrict() can override it.\r
+                                       this.status.noFullScreen = this._uaBlocklist(this.options.noFullScreen);\r
+                                       this._restrictNativeVideoControls();\r
+                                       this._updateButtons();\r
+                                       break;\r
+                               case "noVolume" :\r
+                                       this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.\r
+                                       this.status.noVolume = this._uaBlocklist(this.options.noVolume);\r
+                                       this._updateVolume();\r
+                                       this._updateMute();\r
+                                       break;\r
+                               case "emulateHtml" :\r
+                                       if(this.options[key] !== value) { // To avoid multiple event handlers being created, if true already.\r
+                                               this.options[key] = value;\r
+                                               if(value) {\r
+                                                       this._emulateHtmlBridge();\r
+                                               } else {\r
+                                                       this._destroyHtmlBridge();\r
+                                               }\r
+                                       }\r
+                                       break;\r
+                       }\r
+\r
+                       return this;\r
+               },\r
+               // End of: (Options code adapted from ui.widget.js)\r
+\r
+               _refreshSize: function() {\r
+                       this._setSize(); // update status and jPlayer element size\r
+                       this._addUiClass(); // update the ui class\r
+                       this._updateSize(); // update internal sizes\r
+                       this._updateButtons();\r
+                       this._updateAutohide();\r
+                       this._trigger($.jPlayer.event.resize);\r
+               },\r
+               _setSize: function() {\r
+                       // Determine the current size from the options\r
+                       if(this.options.fullScreen) {\r
+                               this.status.width = this.options.sizeFull.width;\r
+                               this.status.height = this.options.sizeFull.height;\r
+                               this.status.cssClass = this.options.sizeFull.cssClass;\r
+                       } else {\r
+                               this.status.width = this.options.size.width;\r
+                               this.status.height = this.options.size.height;\r
+                               this.status.cssClass = this.options.size.cssClass;\r
+                       }\r
+\r
+                       // Set the size of the jPlayer area.\r
+                       this.element.css({'width': this.status.width, 'height': this.status.height});\r
+               },\r
+               _addUiClass: function() {\r
+                       if(this.ancestorJq.length) {\r
+                               this.ancestorJq.addClass(this.status.cssClass);\r
+                       }\r
+               },\r
+               _removeUiClass: function() {\r
+                       if(this.ancestorJq.length) {\r
+                               this.ancestorJq.removeClass(this.status.cssClass);\r
+                       }\r
+               },\r
+               _updateSize: function() {\r
+                       // The poster uses show/hide so can simply resize it.\r
+                       this.internal.poster.jq.css({'width': this.status.width, 'height': this.status.height});\r
+\r
+                       // Video html or flash resized if necessary at this time, or if native video controls being used.\r
+                       if(!this.status.waitForPlay && this.html.active && this.status.video || this.html.video.available && this.html.used && this.status.nativeVideoControls) {\r
+                               this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height});\r
+                       }\r
+                       else if(!this.status.waitForPlay && this.flash.active && this.status.video) {\r
+                               this.internal.flash.jq.css({'width': this.status.width, 'height': this.status.height});\r
+                       }\r
+               },\r
+               _updateAutohide: function() {\r
+                       var     self = this,\r
+                               event = "mousemove.jPlayer",\r
+                               namespace = ".jPlayerAutohide",\r
+                               eventType = event + namespace,\r
+                               handler = function() {\r
+                                       self.css.jq.gui.fadeIn(self.options.autohide.fadeIn, function() {\r
+                                               clearTimeout(self.internal.autohideId);\r
+                                               self.internal.autohideId = setTimeout( function() {\r
+                                                       self.css.jq.gui.fadeOut(self.options.autohide.fadeOut);\r
+                                               }, self.options.autohide.hold);\r
+                                       });\r
+                               };\r
+\r
+                       if(this.css.jq.gui.length) {\r
+\r
+                               // End animations first so that its callback is executed now.\r
+                               // Otherwise an in progress fadeIn animation still has the callback to fadeOut again.\r
+                               this.css.jq.gui.stop(true, true);\r
+\r
+                               // Removes the fadeOut operation from the fadeIn callback.\r
+                               clearTimeout(this.internal.autohideId);\r
+\r
+                               this.element.unbind(namespace);\r
+                               this.css.jq.gui.unbind(namespace);\r
+\r
+                               if(!this.status.nativeVideoControls) {\r
+                                       if(this.options.fullScreen && this.options.autohide.full || !this.options.fullScreen && this.options.autohide.restored) {\r
+                                               this.element.bind(eventType, handler);\r
+                                               this.css.jq.gui.bind(eventType, handler);\r
+                                               this.css.jq.gui.hide();\r
+                                       } else {\r
+                                               this.css.jq.gui.show();\r
+                                       }\r
+                               } else {\r
+                                       this.css.jq.gui.hide();\r
+                               }\r
+                       }\r
+               },\r
+               fullScreen: function() {\r
+                       this._setOption("fullScreen", true);\r
+               },\r
+               restoreScreen: function() {\r
+                       this._setOption("fullScreen", false);\r
+               },\r
+               _html_initMedia: function() {\r
+                       this.htmlElement.media.src = this.status.src;\r
+\r
+                       if(this.options.preload !== 'none') {\r
+                               this._html_load(); // See function for comments\r
+                       }\r
+                       this._trigger($.jPlayer.event.timeupdate); // The flash generates this event for its solution.\r
+               },\r
+               _html_setAudio: function(media) {\r
+                       var self = this;\r
+                       // Always finds a format due to checks in setMedia()\r
+                       $.each(this.formats, function(priority, format) {\r
+                               if(self.html.support[format] && media[format]) {\r
+                                       self.status.src = media[format];\r
+                                       self.status.format[format] = true;\r
+                                       self.status.formatType = format;\r
+                                       return false;\r
+                               }\r
+                       });\r
+                       this.htmlElement.media = this.htmlElement.audio;\r
+                       this._html_initMedia();\r
+               },\r
+               _html_setVideo: function(media) {\r
+                       var self = this;\r
+                       // Always finds a format due to checks in setMedia()\r
+                       $.each(this.formats, function(priority, format) {\r
+                               if(self.html.support[format] && media[format]) {\r
+                                       self.status.src = media[format];\r
+                                       self.status.format[format] = true;\r
+                                       self.status.formatType = format;\r
+                                       return false;\r
+                               }\r
+                       });\r
+                       if(this.status.nativeVideoControls) {\r
+                               this.htmlElement.video.poster = this._validString(media.poster) ? media.poster : "";\r
+                       }\r
+                       this.htmlElement.media = this.htmlElement.video;\r
+                       this._html_initMedia();\r
+               },\r
+               _html_resetMedia: function() {\r
+                       if(this.htmlElement.media) {\r
+                               if(this.htmlElement.media.id === this.internal.video.id && !this.status.nativeVideoControls) {\r
+                                       this.internal.video.jq.css({'width':'0px', 'height':'0px'});\r
+                               }\r
+                               this.htmlElement.media.pause();\r
+                       }\r
+               },\r
+               _html_clearMedia: function() {\r
+                       if(this.htmlElement.media) {\r
+                               this.htmlElement.media.src = "";\r
+                               this.htmlElement.media.load(); // Stops an old, "in progress" download from continuing the download. Triggers the loadstart, error and emptied events, due to the empty src. Also an abort event if a download was in progress.\r
+                       }\r
+               },\r
+               _html_load: function() {\r
+                       // This function remains to allow the early HTML5 browsers to work, such as Firefox 3.6\r
+                       // A change in the W3C spec for the media.load() command means that this is no longer necessary.\r
+                       // This command should be removed and actually causes minor undesirable effects on some browsers. Such as loading the whole file and not only the metadata.\r
+                       if(this.status.waitForLoad) {\r
+                               this.status.waitForLoad = false;\r
+                               this.htmlElement.media.load();\r
+                       }\r
+                       clearTimeout(this.internal.htmlDlyCmdId);\r
+               },\r
+               _html_play: function(time) {\r
+                       var self = this;\r
+                       this._html_load(); // Loads if required and clears any delayed commands.\r
+\r
+                       this.htmlElement.media.play(); // Before currentTime attempt otherwise Firefox 4 Beta never loads.\r
+\r
+                       if(!isNaN(time)) {\r
+                               try {\r
+                                       this.htmlElement.media.currentTime = time;\r
+                               } catch(err) {\r
+                                       this.internal.htmlDlyCmdId = setTimeout(function() {\r
+                                               self.play(time);\r
+                                       }, 100);\r
+                                       return; // Cancel execution and wait for the delayed command.\r
+                               }\r
+                       }\r
+                       this._html_checkWaitForPlay();\r
+               },\r
+               _html_pause: function(time) {\r
+                       var self = this;\r
+                       \r
+                       if(time > 0) { // We do not want the stop() command, which does pause(0), causing a load operation.\r
+                               this._html_load(); // Loads if required and clears any delayed commands.\r
+                       } else {\r
+                               clearTimeout(this.internal.htmlDlyCmdId);\r
+                       }\r
+\r
+                       // Order of these commands is important for Safari (Win) and IE9. Pause then change currentTime.\r
+                       this.htmlElement.media.pause();\r
+\r
+                       if(!isNaN(time)) {\r
+                               try {\r
+                                       this.htmlElement.media.currentTime = time;\r
+                               } catch(err) {\r
+                                       this.internal.htmlDlyCmdId = setTimeout(function() {\r
+                                               self.pause(time);\r
+                                       }, 100);\r
+                                       return; // Cancel execution and wait for the delayed command.\r
+                               }\r
+                       }\r
+                       if(time > 0) { // Avoids a setMedia() followed by stop() or pause(0) hiding the video play button.\r
+                               this._html_checkWaitForPlay();\r
+                       }\r
+               },\r
+               _html_playHead: function(percent) {\r
+                       var self = this;\r
+                       this._html_load(); // Loads if required and clears any delayed commands.\r
+                       try {\r
+                               if((typeof this.htmlElement.media.seekable === "object") && (this.htmlElement.media.seekable.length > 0)) {\r
+                                       this.htmlElement.media.currentTime = percent * this.htmlElement.media.seekable.end(this.htmlElement.media.seekable.length-1) / 100;\r
+                               } else if(this.htmlElement.media.duration > 0 && !isNaN(this.htmlElement.media.duration)) {\r
+                                       this.htmlElement.media.currentTime = percent * this.htmlElement.media.duration / 100;\r
+                               } else {\r
+                                       throw "e";\r
+                               }\r
+                       } catch(err) {\r
+                               this.internal.htmlDlyCmdId = setTimeout(function() {\r
+                                       self.playHead(percent);\r
+                               }, 100);\r
+                               return; // Cancel execution and wait for the delayed command.\r
+                       }\r
+                       if(!this.status.waitForLoad) {\r
+                               this._html_checkWaitForPlay();\r
+                       }\r
+               },\r
+               _html_checkWaitForPlay: function() {\r
+                       if(this.status.waitForPlay) {\r
+                               this.status.waitForPlay = false;\r
+                               if(this.css.jq.videoPlay.length) {\r
+                                       this.css.jq.videoPlay.hide();\r
+                               }\r
+                               if(this.status.video) {\r
+                                       this.internal.poster.jq.hide();\r
+                                       this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height});\r
+                               }\r
+                       }\r
+               },\r
+               _html_volume: function(v) {\r
+                       if(this.html.audio.available) {\r
+                               this.htmlElement.audio.volume = v;\r
+                       }\r
+                       if(this.html.video.available) {\r
+                               this.htmlElement.video.volume = v;\r
+                       }\r
+               },\r
+               _html_mute: function(m) {\r
+                       if(this.html.audio.available) {\r
+                               this.htmlElement.audio.muted = m;\r
+                       }\r
+                       if(this.html.video.available) {\r
+                               this.htmlElement.video.muted = m;\r
+                       }\r
+               },\r
+               _flash_setAudio: function(media) {\r
+                       var self = this;\r
+                       try {\r
+                               // Always finds a format due to checks in setMedia()\r
+                               $.each(this.formats, function(priority, format) {\r
+                                       if(self.flash.support[format] && media[format]) {\r
+                                               switch (format) {\r
+                                                       case "m4a" :\r
+                                                       case "fla" :\r
+                                                               self._getMovie().fl_setAudio_m4a(media[format]);\r
+                                                               break;\r
+                                                       case "mp3" :\r
+                                                               self._getMovie().fl_setAudio_mp3(media[format]);\r
+                                                               break;\r
+                                               }\r
+                                               self.status.src = media[format];\r
+                                               self.status.format[format] = true;\r
+                                               self.status.formatType = format;\r
+                                               return false;\r
+                                       }\r
+                               });\r
+\r
+                               if(this.options.preload === 'auto') {\r
+                                       this._flash_load();\r
+                                       this.status.waitForLoad = false;\r
+                               }\r
+                       } catch(err) { this._flashError(err); }\r
+               },\r
+               _flash_setVideo: function(media) {\r
+                       var self = this;\r
+                       try {\r
+                               // Always finds a format due to checks in setMedia()\r
+                               $.each(this.formats, function(priority, format) {\r
+                                       if(self.flash.support[format] && media[format]) {\r
+                                               switch (format) {\r
+                                                       case "m4v" :\r
+                                                       case "flv" :\r
+                                                               self._getMovie().fl_setVideo_m4v(media[format]);\r
+                                                               break;\r
+                                               }\r
+                                               self.status.src = media[format];\r
+                                               self.status.format[format] = true;\r
+                                               self.status.formatType = format;\r
+                                               return false;\r
+                                       }\r
+                               });\r
+\r
+                               if(this.options.preload === 'auto') {\r
+                                       this._flash_load();\r
+                                       this.status.waitForLoad = false;\r
+                               }\r
+                       } catch(err) { this._flashError(err); }\r
+               },\r
+               _flash_resetMedia: function() {\r
+                       this.internal.flash.jq.css({'width':'0px', 'height':'0px'}); // Must do via CSS as setting attr() to zero causes a jQuery error in IE.\r
+                       this._flash_pause(NaN);\r
+               },\r
+               _flash_clearMedia: function() {\r
+                       try {\r
+                               this._getMovie().fl_clearMedia();\r
+                       } catch(err) { this._flashError(err); }\r
+               },\r
+               _flash_load: function() {\r
+                       try {\r
+                               this._getMovie().fl_load();\r
+                       } catch(err) { this._flashError(err); }\r
+                       this.status.waitForLoad = false;\r
+               },\r
+               _flash_play: function(time) {\r
+                       try {\r
+                               this._getMovie().fl_play(time);\r
+                       } catch(err) { this._flashError(err); }\r
+                       this.status.waitForLoad = false;\r
+                       this._flash_checkWaitForPlay();\r
+               },\r
+               _flash_pause: function(time) {\r
+                       try {\r
+                               this._getMovie().fl_pause(time);\r
+                       } catch(err) { this._flashError(err); }\r
+                       if(time > 0) { // Avoids a setMedia() followed by stop() or pause(0) hiding the video play button.\r
+                               this.status.waitForLoad = false;\r
+                               this._flash_checkWaitForPlay();\r
+                       }\r
+               },\r
+               _flash_playHead: function(p) {\r
+                       try {\r
+                               this._getMovie().fl_play_head(p);\r
+                       } catch(err) { this._flashError(err); }\r
+                       if(!this.status.waitForLoad) {\r
+                               this._flash_checkWaitForPlay();\r
+                       }\r
+               },\r
+               _flash_checkWaitForPlay: function() {\r
+                       if(this.status.waitForPlay) {\r
+                               this.status.waitForPlay = false;\r
+                               if(this.css.jq.videoPlay.length) {\r
+                                       this.css.jq.videoPlay.hide();\r
+                               }\r
+                               if(this.status.video) {\r
+                                       this.internal.poster.jq.hide();\r
+                                       this.internal.flash.jq.css({'width': this.status.width, 'height': this.status.height});\r
+                               }\r
+                       }\r
+               },\r
+               _flash_volume: function(v) {\r
+                       try {\r
+                               this._getMovie().fl_volume(v);\r
+                       } catch(err) { this._flashError(err); }\r
+               },\r
+               _flash_mute: function(m) {\r
+                       try {\r
+                               this._getMovie().fl_mute(m);\r
+                       } catch(err) { this._flashError(err); }\r
+               },\r
+               _getMovie: function() {\r
+                       return document[this.internal.flash.id];\r
+               },\r
+               _checkForFlash: function (version) {\r
+                       // Function checkForFlash adapted from FlashReplace by Robert Nyman\r
+                       // http://code.google.com/p/flashreplace/\r
+                       var flashIsInstalled = false;\r
+                       var flash;\r
+                       if(window.ActiveXObject){\r
+                               try{\r
+                                       flash = new ActiveXObject(("ShockwaveFlash.ShockwaveFlash." + version));\r
+                                       flashIsInstalled = true;\r
+                               }\r
+                               catch(e){\r
+                                       // Throws an error if the version isn't available                       \r
+                               }\r
+                       }\r
+                       else if(navigator.plugins && navigator.mimeTypes.length > 0){\r
+                               flash = navigator.plugins["Shockwave Flash"];\r
+                               if(flash){\r
+                                       var flashVersion = navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/, "$1");\r
+                                       if(flashVersion >= version){\r
+                                               flashIsInstalled = true;\r
+                                       }\r
+                               }\r
+                       }\r
+                       return flashIsInstalled;\r
+               },\r
+               _validString: function(url) {\r
+                       return (url && typeof url === "string"); // Empty strings return false\r
+               },\r
+               _limitValue: function(value, min, max) {\r
+                       return (value < min) ? min : ((value > max) ? max : value);\r
+               },\r
+               _urlNotSetError: function(context) {\r
+                       this._error( {\r
+                               type: $.jPlayer.error.URL_NOT_SET,\r
+                               context: context,\r
+                               message: $.jPlayer.errorMsg.URL_NOT_SET,\r
+                               hint: $.jPlayer.errorHint.URL_NOT_SET\r
+                       });\r
+               },\r
+               _flashError: function(error) {\r
+                       var errorType;\r
+                       if(!this.internal.ready) {\r
+                               errorType = "FLASH";\r
+                       } else {\r
+                               errorType = "FLASH_DISABLED";\r
+                       }\r
+                       this._error( {\r
+                               type: $.jPlayer.error[errorType],\r
+                               context: this.internal.flash.swf,\r
+                               message: $.jPlayer.errorMsg[errorType] + error.message,\r
+                               hint: $.jPlayer.errorHint[errorType]\r
+                       });\r
+                       // Allow the audio player to recover if display:none and then shown again, or with position:fixed on Firefox.\r
+                       // This really only affects audio in a media player, as an audio player could easily move the jPlayer element away from such issues.\r
+                       this.internal.flash.jq.css({'width':'1px', 'height':'1px'});\r
+               },\r
+               _error: function(error) {\r
+                       this._trigger($.jPlayer.event.error, error);\r
+                       if(this.options.errorAlerts) {\r
+                               this._alert("Error!" + (error.message ? "\n\n" + error.message : "") + (error.hint ? "\n\n" + error.hint : "") + "\n\nContext: " + error.context);\r
+                       }\r
+               },\r
+               _warning: function(warning) {\r
+                       this._trigger($.jPlayer.event.warning, undefined, warning);\r
+                       if(this.options.warningAlerts) {\r
+                               this._alert("Warning!" + (warning.message ? "\n\n" + warning.message : "") + (warning.hint ? "\n\n" + warning.hint : "") + "\n\nContext: " + warning.context);\r
+                       }\r
+               },\r
+               _alert: function(message) {\r
+                       alert("jPlayer " + this.version.script + " : id='" + this.internal.self.id +"' : " + message);\r
+               },\r
+               _emulateHtmlBridge: function() {\r
+                       var self = this,\r
+                       methods = $.jPlayer.emulateMethods;\r
+\r
+                       // Emulate methods on jPlayer's DOM element.\r
+                       $.each( $.jPlayer.emulateMethods.split(/\s+/g), function(i, name) {\r
+                               self.internal.domNode[name] = function(arg) {\r
+                                       self[name](arg);\r
+                               };\r
+\r
+                       });\r
+\r
+                       // Bubble jPlayer events to its DOM element.\r
+                       $.each($.jPlayer.event, function(eventName,eventType) {\r
+                               var nativeEvent = true;\r
+                               $.each( $.jPlayer.reservedEvent.split(/\s+/g), function(i, name) {\r
+                                       if(name === eventName) {\r
+                                               nativeEvent = false;\r
+                                               return false;\r
+                                       }\r
+                               });\r
+                               if(nativeEvent) {\r
+                                       self.element.bind(eventType + ".jPlayer.jPlayerHtml", function() { // With .jPlayer & .jPlayerHtml namespaces.\r
+                                               self._emulateHtmlUpdate();\r
+                                               var domEvent = document.createEvent("Event");\r
+                                               domEvent.initEvent(eventName, false, true);\r
+                                               self.internal.domNode.dispatchEvent(domEvent);\r
+                                       });\r
+                               }\r
+                               // The error event would require a special case\r
+                       });\r
+\r
+                       // IE9 has a readyState property on all elements. The document should have it, but all (except media) elements inherit it in IE9. This conflicts with Popcorn, which polls the readyState.\r
+               },\r
+               _emulateHtmlUpdate: function() {\r
+                       var self = this;\r
+\r
+                       $.each( $.jPlayer.emulateStatus.split(/\s+/g), function(i, name) {\r
+                               self.internal.domNode[name] = self.status[name];\r
+                       });\r
+                       $.each( $.jPlayer.emulateOptions.split(/\s+/g), function(i, name) {\r
+                               self.internal.domNode[name] = self.options[name];\r
+                       });\r
+               },\r
+               _destroyHtmlBridge: function() {\r
+                       var self = this;\r
+\r
+                       // Bridge event handlers are also removed by destroy() through .jPlayer namespace.\r
+                       this.element.unbind(".jPlayerHtml"); // Remove all event handlers created by the jPlayer bridge. So you can change the emulateHtml option.\r
+\r
+                       // Remove the methods and properties\r
+                       var emulated = $.jPlayer.emulateMethods + " " + $.jPlayer.emulateStatus + " " + $.jPlayer.emulateOptions;\r
+                       $.each( emulated.split(/\s+/g), function(i, name) {\r
+                               delete self.internal.domNode[name];\r
+                       });\r
+               }\r
+       };\r
+\r
+       $.jPlayer.error = {\r
+               FLASH: "e_flash",\r
+               FLASH_DISABLED: "e_flash_disabled",\r
+               NO_SOLUTION: "e_no_solution",\r
+               NO_SUPPORT: "e_no_support",\r
+               URL: "e_url",\r
+               URL_NOT_SET: "e_url_not_set",\r
+               VERSION: "e_version"\r
+       };\r
+\r
+       $.jPlayer.errorMsg = {\r
+               FLASH: "jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ", // Used in: _flashError()\r
+               FLASH_DISABLED: "jPlayer's Flash fallback has been disabled by the browser due to the CSS rules you have used. Details: ", // Used in: _flashError()\r
+               NO_SOLUTION: "No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.", // Used in: _init()\r
+               NO_SUPPORT: "It is not possible to play any media format provided in setMedia() on this browser using your current options.", // Used in: setMedia()\r
+               URL: "Media URL could not be loaded.", // Used in: jPlayerFlashEvent() and _addHtmlEventListeners()\r
+               URL_NOT_SET: "Attempt to issue media playback commands, while no media url is set.", // Used in: load(), play(), pause(), stop() and playHead()\r
+               VERSION: "jPlayer " + $.jPlayer.prototype.version.script + " needs Jplayer.swf version " + $.jPlayer.prototype.version.needFlash + " but found " // Used in: jPlayerReady()\r
+       };\r
+\r
+       $.jPlayer.errorHint = {\r
+               FLASH: "Check your swfPath option and that Jplayer.swf is there.",\r
+               FLASH_DISABLED: "Check that you have not display:none; the jPlayer entity or any ancestor.",\r
+               NO_SOLUTION: "Review the jPlayer options: support and supplied.",\r
+               NO_SUPPORT: "Video or audio formats defined in the supplied option are missing.",\r
+               URL: "Check media URL is valid.",\r
+               URL_NOT_SET: "Use setMedia() to set the media URL.",\r
+               VERSION: "Update jPlayer files."\r
+       };\r
+\r
+       $.jPlayer.warning = {\r
+               CSS_SELECTOR_COUNT: "e_css_selector_count",\r
+               CSS_SELECTOR_METHOD: "e_css_selector_method",\r
+               CSS_SELECTOR_STRING: "e_css_selector_string",\r
+               OPTION_KEY: "e_option_key"\r
+       };\r
+\r
+       $.jPlayer.warningMsg = {\r
+               CSS_SELECTOR_COUNT: "The number of css selectors found did not equal one: ",\r
+               CSS_SELECTOR_METHOD: "The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.",\r
+               CSS_SELECTOR_STRING: "The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.",\r
+               OPTION_KEY: "The option requested in jPlayer('option') is undefined."\r
+       };\r
+\r
+       $.jPlayer.warningHint = {\r
+               CSS_SELECTOR_COUNT: "Check your css selector and the ancestor.",\r
+               CSS_SELECTOR_METHOD: "Check your method name.",\r
+               CSS_SELECTOR_STRING: "Check your css selector is a string.",\r
+               OPTION_KEY: "Check your option name."\r
+       };\r
+})(jQuery);\r