jquery.jplayer.js 118 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506
  1. /*
  2. * jPlayer Plugin for jQuery JavaScript Library
  3. * http://www.jplayer.org
  4. *
  5. * Copyright (c) 2009 - 2014 Happyworm Ltd
  6. * Licensed under the MIT license.
  7. * http://opensource.org/licenses/MIT
  8. *
  9. * Author: Mark J Panaghiston
  10. * Version: 2.9.2
  11. * Date: 14th December 2014
  12. */
  13. /* Support for Zepto 1.0 compiled with optional data module.
  14. * For AMD or NODE/CommonJS support, you will need to manually switch the related 2 lines in the code below.
  15. * Search terms: "jQuery Switch" and "Zepto Switch"
  16. */
  17. (function (root, factory) {
  18. if (typeof define === 'function' && define.amd) {
  19. // AMD. Register as an anonymous module.
  20. define(['jquery'], factory); // jQuery Switch
  21. // define(['zepto'], factory); // Zepto Switch
  22. } else if (typeof exports === 'object') {
  23. // Node/CommonJS
  24. factory(require('jquery')); // jQuery Switch
  25. //factory(require('zepto')); // Zepto Switch
  26. } else {
  27. // Browser globals
  28. if(root.jQuery) { // Use jQuery if available
  29. factory(root.jQuery);
  30. } else { // Otherwise, use Zepto
  31. factory(root.Zepto);
  32. }
  33. }
  34. }(this, function ($, undefined) {
  35. // Adapted from jquery.ui.widget.js (1.8.7): $.widget.bridge - Tweaked $.data(this,XYZ) to $(this).data(XYZ) for Zepto
  36. $.fn.jPlayer = function( options ) {
  37. var name = "jPlayer";
  38. var isMethodCall = typeof options === "string",
  39. args = Array.prototype.slice.call( arguments, 1 ),
  40. returnValue = this;
  41. // allow multiple hashes to be passed on init
  42. options = !isMethodCall && args.length ?
  43. $.extend.apply( null, [ true, options ].concat(args) ) :
  44. options;
  45. // prevent calls to internal methods
  46. if ( isMethodCall && options.charAt( 0 ) === "_" ) {
  47. return returnValue;
  48. }
  49. if ( isMethodCall ) {
  50. this.each(function() {
  51. var instance = $(this).data( name ),
  52. methodValue = instance && $.isFunction( instance[options] ) ?
  53. instance[ options ].apply( instance, args ) :
  54. instance;
  55. if ( methodValue !== instance && methodValue !== undefined ) {
  56. returnValue = methodValue;
  57. return false;
  58. }
  59. });
  60. } else {
  61. this.each(function() {
  62. var instance = $(this).data( name );
  63. if ( instance ) {
  64. // 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.
  65. instance.option( options || {} ); // The new constructor only changes the options. Changing options only has basic support atm.
  66. } else {
  67. $(this).data( name, new $.jPlayer( options, this ) );
  68. }
  69. });
  70. }
  71. return returnValue;
  72. };
  73. $.jPlayer = function( options, element ) {
  74. // allow instantiation without initializing for simple inheritance
  75. if ( arguments.length ) {
  76. this.element = $(element);
  77. this.options = $.extend(true, {},
  78. this.options,
  79. options
  80. );
  81. var self = this;
  82. this.element.bind( "remove.jPlayer", function() {
  83. self.destroy();
  84. });
  85. this._init();
  86. }
  87. };
  88. // End of: (Adapted from jquery.ui.widget.js (1.8.7))
  89. // Zepto is missing one of the animation methods.
  90. if(typeof $.fn.stop !== 'function') {
  91. $.fn.stop = function() {};
  92. }
  93. // Emulated HTML5 methods and properties
  94. $.jPlayer.emulateMethods = "load play pause";
  95. $.jPlayer.emulateStatus = "src readyState networkState currentTime duration paused ended playbackRate";
  96. $.jPlayer.emulateOptions = "muted volume";
  97. // Reserved event names generated by jPlayer that are not part of the HTML5 Media element spec
  98. $.jPlayer.reservedEvent = "ready flashreset resize repeat error warning";
  99. // Events generated by jPlayer
  100. $.jPlayer.event = {};
  101. $.each(
  102. [
  103. 'ready',
  104. 'setmedia', // Fires when the media is set
  105. '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.
  106. 'resize', // Occurs when the size changes through a full/restore screen operation or if the size/sizeFull options are changed.
  107. 'repeat', // Occurs when the repeat status changes. Usually through clicks on the repeat button of the interface.
  108. 'click', // Occurs when the user clicks on one of the following: poster image, html video, flash video.
  109. 'error', // Event error code in event.jPlayer.error.type. See $.jPlayer.error
  110. 'warning', // Event warning code in event.jPlayer.warning.type. See $.jPlayer.warning
  111. // Other events match HTML5 spec.
  112. 'loadstart',
  113. 'progress',
  114. 'suspend',
  115. 'abort',
  116. 'emptied',
  117. 'stalled',
  118. 'play',
  119. 'pause',
  120. 'loadedmetadata',
  121. 'loadeddata',
  122. 'waiting',
  123. 'playing',
  124. 'canplay',
  125. 'canplaythrough',
  126. 'seeking',
  127. 'seeked',
  128. 'timeupdate',
  129. 'ended',
  130. 'ratechange',
  131. 'durationchange',
  132. 'volumechange'
  133. ],
  134. function() {
  135. $.jPlayer.event[ this ] = 'jPlayer_' + this;
  136. }
  137. );
  138. $.jPlayer.htmlEvent = [ // These HTML events are bubbled through to the jPlayer event, without any internal action.
  139. "loadstart",
  140. // "progress", // jPlayer uses internally before bubbling.
  141. // "suspend", // jPlayer uses internally before bubbling.
  142. "abort",
  143. // "error", // jPlayer uses internally before bubbling.
  144. "emptied",
  145. "stalled",
  146. // "play", // jPlayer uses internally before bubbling.
  147. // "pause", // jPlayer uses internally before bubbling.
  148. "loadedmetadata",
  149. // "loadeddata", // jPlayer uses internally before bubbling.
  150. // "waiting", // jPlayer uses internally before bubbling.
  151. // "playing", // jPlayer uses internally before bubbling.
  152. "canplay",
  153. "canplaythrough"
  154. // "seeking", // jPlayer uses internally before bubbling.
  155. // "seeked", // jPlayer uses internally before bubbling.
  156. // "timeupdate", // jPlayer uses internally before bubbling.
  157. // "ended", // jPlayer uses internally before bubbling.
  158. // "ratechange" // jPlayer uses internally before bubbling.
  159. // "durationchange" // jPlayer uses internally before bubbling.
  160. // "volumechange" // jPlayer uses internally before bubbling.
  161. ];
  162. $.jPlayer.pause = function() {
  163. $.jPlayer.prototype.destroyRemoved();
  164. $.each($.jPlayer.prototype.instances, function(i, element) {
  165. if(element.data("jPlayer").status.srcSet) { // Check that media is set otherwise would cause error event.
  166. element.jPlayer("pause");
  167. }
  168. });
  169. };
  170. // Default for jPlayer option.timeFormat
  171. $.jPlayer.timeFormat = {
  172. showHour: false,
  173. showMin: true,
  174. showSec: true,
  175. padHour: false,
  176. padMin: true,
  177. padSec: true,
  178. sepHour: ":",
  179. sepMin: ":",
  180. sepSec: ""
  181. };
  182. var ConvertTime = function() {
  183. this.init();
  184. };
  185. ConvertTime.prototype = {
  186. init: function() {
  187. this.options = {
  188. timeFormat: $.jPlayer.timeFormat
  189. };
  190. },
  191. time: function(s) { // function used on jPlayer.prototype._convertTime to enable per instance options.
  192. s = (s && typeof s === 'number') ? s : 0;
  193. var myTime = new Date(s * 1000),
  194. hour = myTime.getUTCHours(),
  195. min = this.options.timeFormat.showHour ? myTime.getUTCMinutes() : myTime.getUTCMinutes() + hour * 60,
  196. sec = this.options.timeFormat.showMin ? myTime.getUTCSeconds() : myTime.getUTCSeconds() + min * 60,
  197. strHour = (this.options.timeFormat.padHour && hour < 10) ? "0" + hour : hour,
  198. strMin = (this.options.timeFormat.padMin && min < 10) ? "0" + min : min,
  199. strSec = (this.options.timeFormat.padSec && sec < 10) ? "0" + sec : sec,
  200. strTime = "";
  201. strTime += this.options.timeFormat.showHour ? strHour + this.options.timeFormat.sepHour : "";
  202. strTime += this.options.timeFormat.showMin ? strMin + this.options.timeFormat.sepMin : "";
  203. strTime += this.options.timeFormat.showSec ? strSec + this.options.timeFormat.sepSec : "";
  204. return strTime;
  205. }
  206. };
  207. var myConvertTime = new ConvertTime();
  208. $.jPlayer.convertTime = function(s) {
  209. return myConvertTime.time(s);
  210. };
  211. // Adapting jQuery 1.4.4 code for jQuery.browser. Required since jQuery 1.3.2 does not detect Chrome as webkit.
  212. $.jPlayer.uaBrowser = function( userAgent ) {
  213. var ua = userAgent.toLowerCase();
  214. // Useragent RegExp
  215. var rwebkit = /(webkit)[ \/]([\w.]+)/;
  216. var ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/;
  217. var rmsie = /(msie) ([\w.]+)/;
  218. var rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/;
  219. var match = rwebkit.exec( ua ) ||
  220. ropera.exec( ua ) ||
  221. rmsie.exec( ua ) ||
  222. ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
  223. [];
  224. return { browser: match[1] || "", version: match[2] || "0" };
  225. };
  226. // Platform sniffer for detecting mobile devices
  227. $.jPlayer.uaPlatform = function( userAgent ) {
  228. var ua = userAgent.toLowerCase();
  229. // Useragent RegExp
  230. var rplatform = /(ipad|iphone|ipod|android|blackberry|playbook|windows ce|webos)/;
  231. var rtablet = /(ipad|playbook)/;
  232. var randroid = /(android)/;
  233. var rmobile = /(mobile)/;
  234. var platform = rplatform.exec( ua ) || [];
  235. var tablet = rtablet.exec( ua ) ||
  236. !rmobile.exec( ua ) && randroid.exec( ua ) ||
  237. [];
  238. if(platform[1]) {
  239. platform[1] = platform[1].replace(/\s/g, "_"); // Change whitespace to underscore. Enables dot notation.
  240. }
  241. return { platform: platform[1] || "", tablet: tablet[1] || "" };
  242. };
  243. $.jPlayer.browser = {
  244. };
  245. $.jPlayer.platform = {
  246. };
  247. var browserMatch = $.jPlayer.uaBrowser(navigator.userAgent);
  248. if ( browserMatch.browser ) {
  249. $.jPlayer.browser[ browserMatch.browser ] = true;
  250. $.jPlayer.browser.version = browserMatch.version;
  251. }
  252. var platformMatch = $.jPlayer.uaPlatform(navigator.userAgent);
  253. if ( platformMatch.platform ) {
  254. $.jPlayer.platform[ platformMatch.platform ] = true;
  255. $.jPlayer.platform.mobile = !platformMatch.tablet;
  256. $.jPlayer.platform.tablet = !!platformMatch.tablet;
  257. }
  258. // Internet Explorer (IE) Browser Document Mode Sniffer. Based on code at:
  259. // http://msdn.microsoft.com/en-us/library/cc288325%28v=vs.85%29.aspx#GetMode
  260. $.jPlayer.getDocMode = function() {
  261. var docMode;
  262. if ($.jPlayer.browser.msie) {
  263. if (document.documentMode) { // IE8 or later
  264. docMode = document.documentMode;
  265. } else { // IE 5-7
  266. docMode = 5; // Assume quirks mode unless proven otherwise
  267. if (document.compatMode) {
  268. if (document.compatMode === "CSS1Compat") {
  269. docMode = 7; // standards mode
  270. }
  271. }
  272. }
  273. }
  274. return docMode;
  275. };
  276. $.jPlayer.browser.documentMode = $.jPlayer.getDocMode();
  277. $.jPlayer.nativeFeatures = {
  278. init: function() {
  279. /* Fullscreen function naming influenced by W3C naming.
  280. * No support for: Mozilla Proposal: https://wiki.mozilla.org/Gecko:FullScreenAPI
  281. */
  282. var d = document,
  283. v = d.createElement('video'),
  284. spec = {
  285. // http://www.w3.org/TR/fullscreen/
  286. w3c: [
  287. 'fullscreenEnabled',
  288. 'fullscreenElement',
  289. 'requestFullscreen',
  290. 'exitFullscreen',
  291. 'fullscreenchange',
  292. 'fullscreenerror'
  293. ],
  294. // https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode
  295. moz: [
  296. 'mozFullScreenEnabled',
  297. 'mozFullScreenElement',
  298. 'mozRequestFullScreen',
  299. 'mozCancelFullScreen',
  300. 'mozfullscreenchange',
  301. 'mozfullscreenerror'
  302. ],
  303. // http://developer.apple.com/library/safari/#documentation/WebKit/Reference/ElementClassRef/Element/Element.html
  304. // http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html
  305. webkit: [
  306. '',
  307. 'webkitCurrentFullScreenElement',
  308. 'webkitRequestFullScreen',
  309. 'webkitCancelFullScreen',
  310. 'webkitfullscreenchange',
  311. ''
  312. ],
  313. // http://developer.apple.com/library/safari/#documentation/AudioVideo/Reference/HTMLVideoElementClassReference/HTMLVideoElement/HTMLVideoElement.html
  314. // https://developer.apple.com/library/safari/samplecode/HTML5VideoEventFlow/Listings/events_js.html#//apple_ref/doc/uid/DTS40010085-events_js-DontLinkElementID_5
  315. // Events: 'webkitbeginfullscreen' and 'webkitendfullscreen'
  316. webkitVideo: [
  317. 'webkitSupportsFullscreen',
  318. 'webkitDisplayingFullscreen',
  319. 'webkitEnterFullscreen',
  320. 'webkitExitFullscreen',
  321. '',
  322. ''
  323. ],
  324. ms: [
  325. '',
  326. 'msFullscreenElement',
  327. 'msRequestFullscreen',
  328. 'msExitFullscreen',
  329. 'MSFullscreenChange',
  330. 'MSFullscreenError'
  331. ]
  332. },
  333. specOrder = [
  334. 'w3c',
  335. 'moz',
  336. 'webkit',
  337. 'webkitVideo',
  338. 'ms'
  339. ],
  340. fs, i, il;
  341. this.fullscreen = fs = {
  342. support: {
  343. w3c: !!d[spec.w3c[0]],
  344. moz: !!d[spec.moz[0]],
  345. webkit: typeof d[spec.webkit[3]] === 'function',
  346. webkitVideo: typeof v[spec.webkitVideo[2]] === 'function',
  347. ms: typeof v[spec.ms[2]] === 'function'
  348. },
  349. used: {}
  350. };
  351. // Store the name of the spec being used and as a handy boolean.
  352. for(i = 0, il = specOrder.length; i < il; i++) {
  353. var n = specOrder[i];
  354. if(fs.support[n]) {
  355. fs.spec = n;
  356. fs.used[n] = true;
  357. break;
  358. }
  359. }
  360. if(fs.spec) {
  361. var s = spec[fs.spec];
  362. fs.api = {
  363. fullscreenEnabled: true,
  364. fullscreenElement: function(elem) {
  365. elem = elem ? elem : d; // Video element required for webkitVideo
  366. return elem[s[1]];
  367. },
  368. requestFullscreen: function(elem) {
  369. return elem[s[2]](); // Chrome and Opera want parameter (Element.ALLOW_KEYBOARD_INPUT) but Safari fails if flag used.
  370. },
  371. exitFullscreen: function(elem) {
  372. elem = elem ? elem : d; // Video element required for webkitVideo
  373. return elem[s[3]]();
  374. }
  375. };
  376. fs.event = {
  377. fullscreenchange: s[4],
  378. fullscreenerror: s[5]
  379. };
  380. } else {
  381. fs.api = {
  382. fullscreenEnabled: false,
  383. fullscreenElement: function() {
  384. return null;
  385. },
  386. requestFullscreen: function() {},
  387. exitFullscreen: function() {}
  388. };
  389. fs.event = {};
  390. }
  391. }
  392. };
  393. $.jPlayer.nativeFeatures.init();
  394. // The keyboard control system.
  395. // The current jPlayer instance in focus.
  396. $.jPlayer.focus = null;
  397. // The list of element node names to ignore with key controls.
  398. $.jPlayer.keyIgnoreElementNames = "A INPUT TEXTAREA SELECT BUTTON";
  399. // The function that deals with key presses.
  400. var keyBindings = function(event) {
  401. var f = $.jPlayer.focus,
  402. ignoreKey;
  403. // A jPlayer instance must be in focus. ie., keyEnabled and the last one played.
  404. if(f) {
  405. // What generated the key press?
  406. $.each( $.jPlayer.keyIgnoreElementNames.split(/\s+/g), function(i, name) {
  407. // The strings should already be uppercase.
  408. if(event.target.nodeName.toUpperCase() === name.toUpperCase()) {
  409. ignoreKey = true;
  410. return false; // exit each.
  411. }
  412. });
  413. if(!ignoreKey) {
  414. // See if the key pressed matches any of the bindings.
  415. $.each(f.options.keyBindings, function(action, binding) {
  416. // The binding could be a null when the default has been disabled. ie., 1st clause in if()
  417. if(
  418. (binding && $.isFunction(binding.fn)) &&
  419. ((typeof binding.key === 'number' && event.which === binding.key) ||
  420. (typeof binding.key === 'string' && event.key === binding.key))
  421. ) {
  422. event.preventDefault(); // Key being used by jPlayer, so prevent default operation.
  423. binding.fn(f);
  424. return false; // exit each.
  425. }
  426. });
  427. }
  428. }
  429. };
  430. $.jPlayer.keys = function(en) {
  431. var event = "keydown.jPlayer";
  432. // Remove any binding, just in case enabled more than once.
  433. $(document.documentElement).unbind(event);
  434. if(en) {
  435. $(document.documentElement).bind(event, keyBindings);
  436. }
  437. };
  438. // Enable the global key control handler ready for any jPlayer instance with the keyEnabled option enabled.
  439. $.jPlayer.keys(true);
  440. $.jPlayer.prototype = {
  441. count: 0, // Static Variable: Change it via prototype.
  442. version: { // Static Object
  443. script: "2.9.2",
  444. needFlash: "2.9.0",
  445. flash: "unknown"
  446. },
  447. options: { // Instanced in $.jPlayer() constructor
  448. swfPath: "js", // Path to jquery.jplayer.swf. Can be relative, absolute or server root relative.
  449. solution: "html, flash", // Valid solutions: html, flash, aurora. Order defines priority. 1st is highest,
  450. supplied: "mp3", // Defines which formats jPlayer will try and support and the priority by the order. 1st is highest,
  451. auroraFormats: "wav", // List the aurora.js codecs being loaded externally. Its core supports "wav". Specify format in jPlayer context. EG., The aac.js codec gives the "m4a" format.
  452. preload: 'metadata', // HTML5 Spec values: none, metadata, auto.
  453. volume: 0.8, // The volume. Number 0 to 1.
  454. muted: false,
  455. remainingDuration: false, // When true, the remaining time is shown in the duration GUI element.
  456. toggleDuration: false, // When true, clicks on the duration toggle between the duration and remaining display.
  457. captureDuration: true, // When true, clicks on the duration are captured and no longer propagate up the DOM.
  458. playbackRate: 1,
  459. defaultPlaybackRate: 1,
  460. minPlaybackRate: 0.5,
  461. maxPlaybackRate: 4,
  462. wmode: "opaque", // Valid wmode: window, transparent, opaque, direct, gpu.
  463. backgroundColor: "#000000", // To define the jPlayer div and Flash background color.
  464. cssSelectorAncestor: "#jp_container_1",
  465. 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.
  466. videoPlay: ".jp-video-play", // *
  467. play: ".jp-play",
  468. pause: ".jp-pause",
  469. stop: ".jp-stop",
  470. seekBar: ".jp-seek-bar",
  471. playBar: ".jp-play-bar",
  472. mute: ".jp-mute",
  473. unmute: ".jp-unmute",
  474. volumeBar: ".jp-volume-bar",
  475. volumeBarValue: ".jp-volume-bar-value",
  476. volumeMax: ".jp-volume-max",
  477. playbackRateBar: ".jp-playback-rate-bar",
  478. playbackRateBarValue: ".jp-playback-rate-bar-value",
  479. currentTime: ".jp-current-time",
  480. duration: ".jp-duration",
  481. title: ".jp-title",
  482. fullScreen: ".jp-full-screen", // *
  483. restoreScreen: ".jp-restore-screen", // *
  484. repeat: ".jp-repeat",
  485. repeatOff: ".jp-repeat-off",
  486. gui: ".jp-gui", // The interface used with autohide feature.
  487. noSolution: ".jp-no-solution" // For error feedback when jPlayer cannot find a solution.
  488. },
  489. stateClass: { // Classes added to the cssSelectorAncestor to indicate the state.
  490. playing: "jp-state-playing",
  491. seeking: "jp-state-seeking",
  492. muted: "jp-state-muted",
  493. looped: "jp-state-looped",
  494. fullScreen: "jp-state-full-screen",
  495. noVolume: "jp-state-no-volume"
  496. },
  497. useStateClassSkin: false, // A state class skin relies on the state classes to change the visual appearance. The single control toggles the effect, for example: play then pause, mute then unmute.
  498. autoBlur: true, // GUI control handlers will drop focus after clicks.
  499. smoothPlayBar: false, // Smooths the play bar transitions, which affects clicks and short media with big changes per second.
  500. fullScreen: false, // Native Full Screen
  501. fullWindow: false,
  502. autohide: {
  503. restored: false, // Controls the interface autohide feature.
  504. full: true, // Controls the interface autohide feature.
  505. fadeIn: 200, // Milliseconds. The period of the fadeIn anim.
  506. fadeOut: 600, // Milliseconds. The period of the fadeOut anim.
  507. hold: 1000 // Milliseconds. The period of the pause before autohide beings.
  508. },
  509. loop: false,
  510. repeat: function(event) { // The default jPlayer repeat event handler
  511. if(event.jPlayer.options.loop) {
  512. $(this).unbind(".jPlayerRepeat").bind($.jPlayer.event.ended + ".jPlayer.jPlayerRepeat", function() {
  513. $(this).jPlayer("play");
  514. });
  515. } else {
  516. $(this).unbind(".jPlayerRepeat");
  517. }
  518. },
  519. nativeVideoControls: {
  520. // Works well on standard browsers.
  521. // Phone and tablet browsers can have problems with the controls disappearing.
  522. },
  523. noFullWindow: {
  524. msie: /msie [0-6]\./,
  525. ipad: /ipad.*?os [0-4]\./,
  526. iphone: /iphone/,
  527. ipod: /ipod/,
  528. android_pad: /android [0-3]\.(?!.*?mobile)/,
  529. android_phone: /(?=.*android)(?!.*chrome)(?=.*mobile)/,
  530. blackberry: /blackberry/,
  531. windows_ce: /windows ce/,
  532. iemobile: /iemobile/,
  533. webos: /webos/
  534. },
  535. noVolume: {
  536. ipad: /ipad/,
  537. iphone: /iphone/,
  538. ipod: /ipod/,
  539. android_pad: /android(?!.*?mobile)/,
  540. android_phone: /android.*?mobile/,
  541. blackberry: /blackberry/,
  542. windows_ce: /windows ce/,
  543. iemobile: /iemobile/,
  544. webos: /webos/,
  545. playbook: /playbook/
  546. },
  547. timeFormat: {
  548. // Specific time format for this instance. The supported options are defined in $.jPlayer.timeFormat
  549. // For the undefined options we use the default from $.jPlayer.timeFormat
  550. },
  551. keyEnabled: false, // Enables keyboard controls.
  552. audioFullScreen: false, // Enables keyboard controls to enter full screen with audio media.
  553. keyBindings: { // The key control object, defining the key codes and the functions to execute.
  554. // The parameter, f = $.jPlayer.focus, will be checked truethy before attempting to call any of these functions.
  555. // Properties may be added to this object, in key/fn pairs, to enable other key controls. EG, for the playlist add-on.
  556. play: {
  557. key: 80, // p
  558. fn: function(f) {
  559. if(f.status.paused) {
  560. f.play();
  561. } else {
  562. f.pause();
  563. }
  564. }
  565. },
  566. fullScreen: {
  567. key: 70, // f
  568. fn: function(f) {
  569. if(f.status.video || f.options.audioFullScreen) {
  570. f._setOption("fullScreen", !f.options.fullScreen);
  571. }
  572. }
  573. },
  574. muted: {
  575. key: 77, // m
  576. fn: function(f) {
  577. f._muted(!f.options.muted);
  578. }
  579. },
  580. volumeUp: {
  581. key: 190, // .
  582. fn: function(f) {
  583. f.volume(f.options.volume + 0.1);
  584. }
  585. },
  586. volumeDown: {
  587. key: 188, // ,
  588. fn: function(f) {
  589. f.volume(f.options.volume - 0.1);
  590. }
  591. },
  592. loop: {
  593. key: 76, // l
  594. fn: function(f) {
  595. f._loop(!f.options.loop);
  596. }
  597. }
  598. },
  599. verticalVolume: false, // Calculate volume from the bottom of the volume bar. Default is from the left. Also volume affects either width or height.
  600. verticalPlaybackRate: false,
  601. globalVolume: false, // Set to make volume and muted changes affect all jPlayer instances with this option enabled
  602. idPrefix: "jp", // Prefix for the ids of html elements created by jPlayer. For flash, this must not include characters: . - + * / \
  603. noConflict: "jQuery",
  604. emulateHtml: false, // Emulates the HTML5 Media element on the jPlayer element.
  605. consoleAlerts: true, // Alerts are sent to the console.log() instead of alert().
  606. errorAlerts: false,
  607. warningAlerts: false
  608. },
  609. optionsAudio: {
  610. size: {
  611. width: "0px",
  612. height: "0px",
  613. cssClass: ""
  614. },
  615. sizeFull: {
  616. width: "0px",
  617. height: "0px",
  618. cssClass: ""
  619. }
  620. },
  621. optionsVideo: {
  622. size: {
  623. width: "480px",
  624. height: "270px",
  625. cssClass: "jp-video-270p"
  626. },
  627. sizeFull: {
  628. width: "100%",
  629. height: "100%",
  630. cssClass: "jp-video-full"
  631. }
  632. },
  633. instances: {}, // Static Object
  634. status: { // Instanced in _init()
  635. src: "",
  636. media: {},
  637. paused: true,
  638. format: {},
  639. formatType: "",
  640. waitForPlay: true, // Same as waitForLoad except in case where preloading.
  641. waitForLoad: true,
  642. srcSet: false,
  643. video: false, // True if playing a video
  644. seekPercent: 0,
  645. currentPercentRelative: 0,
  646. currentPercentAbsolute: 0,
  647. currentTime: 0,
  648. duration: 0,
  649. remaining: 0,
  650. videoWidth: 0, // Intrinsic width of the video in pixels.
  651. videoHeight: 0, // Intrinsic height of the video in pixels.
  652. readyState: 0,
  653. networkState: 0,
  654. playbackRate: 1, // Warning - Now both an option and a status property
  655. ended: 0
  656. /* Persistant status properties created dynamically at _init():
  657. width
  658. height
  659. cssClass
  660. nativeVideoControls
  661. noFullWindow
  662. noVolume
  663. playbackRateEnabled // Warning - Technically, we can have both Flash and HTML, so this might not be correct if the Flash is active. That is a niche case.
  664. */
  665. },
  666. internal: { // Instanced in _init()
  667. ready: false
  668. // instance: undefined
  669. // domNode: undefined
  670. // htmlDlyCmdId: undefined
  671. // autohideId: undefined
  672. // mouse: undefined
  673. // cmdsIgnored
  674. },
  675. solution: { // Static Object: Defines the solutions built in jPlayer.
  676. html: true,
  677. aurora: true,
  678. flash: true
  679. },
  680. // 'MPEG-4 support' : canPlayType('video/mp4; codecs="mp4v.20.8"')
  681. format: { // Static Object
  682. mp3: {
  683. codec: 'audio/mpeg',
  684. flashCanPlay: true,
  685. media: 'audio'
  686. },
  687. m4a: { // AAC / MP4
  688. codec: 'audio/mp4; codecs="mp4a.40.2"',
  689. flashCanPlay: true,
  690. media: 'audio'
  691. },
  692. m3u8a: { // AAC / MP4 / Apple HLS
  693. codec: 'application/vnd.apple.mpegurl; codecs="mp4a.40.2"',
  694. flashCanPlay: false,
  695. media: 'audio'
  696. },
  697. m3ua: { // M3U
  698. codec: 'audio/mpegurl',
  699. flashCanPlay: false,
  700. media: 'audio'
  701. },
  702. oga: { // OGG
  703. codec: 'audio/ogg; codecs="vorbis, opus"',
  704. flashCanPlay: false,
  705. media: 'audio'
  706. },
  707. flac: { // FLAC
  708. codec: 'audio/x-flac',
  709. flashCanPlay: false,
  710. media: 'audio'
  711. },
  712. wav: { // PCM
  713. codec: 'audio/wav; codecs="1"',
  714. flashCanPlay: false,
  715. media: 'audio'
  716. },
  717. webma: { // WEBM
  718. codec: 'audio/webm; codecs="vorbis"',
  719. flashCanPlay: false,
  720. media: 'audio'
  721. },
  722. fla: { // FLV / F4A
  723. codec: 'audio/x-flv',
  724. flashCanPlay: true,
  725. media: 'audio'
  726. },
  727. rtmpa: { // RTMP AUDIO
  728. codec: 'audio/rtmp; codecs="rtmp"',
  729. flashCanPlay: true,
  730. media: 'audio'
  731. },
  732. m4v: { // H.264 / MP4
  733. codec: 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',
  734. flashCanPlay: true,
  735. media: 'video'
  736. },
  737. m3u8v: { // H.264 / AAC / MP4 / Apple HLS
  738. codec: 'application/vnd.apple.mpegurl; codecs="avc1.42E01E, mp4a.40.2"',
  739. flashCanPlay: false,
  740. media: 'video'
  741. },
  742. m3uv: { // M3U
  743. codec: 'audio/mpegurl',
  744. flashCanPlay: false,
  745. media: 'video'
  746. },
  747. ogv: { // OGG
  748. codec: 'video/ogg; codecs="theora, vorbis"',
  749. flashCanPlay: false,
  750. media: 'video'
  751. },
  752. webmv: { // WEBM
  753. codec: 'video/webm; codecs="vorbis, vp8"',
  754. flashCanPlay: false,
  755. media: 'video'
  756. },
  757. flv: { // FLV / F4V
  758. codec: 'video/x-flv',
  759. flashCanPlay: true,
  760. media: 'video'
  761. },
  762. rtmpv: { // RTMP VIDEO
  763. codec: 'video/rtmp; codecs="rtmp"',
  764. flashCanPlay: true,
  765. media: 'video'
  766. }
  767. },
  768. _init: function() {
  769. var self = this;
  770. this.element.empty();
  771. this.status = $.extend({}, this.status); // Copy static to unique instance.
  772. this.internal = $.extend({}, this.internal); // Copy static to unique instance.
  773. // Initialize the time format
  774. this.options.timeFormat = $.extend({}, $.jPlayer.timeFormat, this.options.timeFormat);
  775. // On iOS, assume commands will be ignored before user initiates them.
  776. this.internal.cmdsIgnored = $.jPlayer.platform.ipad || $.jPlayer.platform.iphone || $.jPlayer.platform.ipod;
  777. this.internal.domNode = this.element.get(0);
  778. // Add key bindings focus to 1st jPlayer instanced with key control enabled.
  779. if(this.options.keyEnabled && !$.jPlayer.focus) {
  780. $.jPlayer.focus = this;
  781. }
  782. // A fix for Android where older (2.3) and even some 4.x devices fail to work when changing the *audio* SRC and then playing immediately.
  783. this.androidFix = {
  784. setMedia: false, // True when media set
  785. play: false, // True when a progress event will instruct the media to play
  786. pause: false, // True when a progress event will instruct the media to pause at a time.
  787. time: NaN // The play(time) parameter
  788. };
  789. if($.jPlayer.platform.android) {
  790. this.options.preload = this.options.preload !== 'auto' ? 'metadata' : 'auto'; // Default to metadata, but allow auto.
  791. }
  792. this.formats = []; // Array based on supplied string option. Order defines priority.
  793. this.solutions = []; // Array based on solution string option. Order defines priority.
  794. this.require = {}; // Which media types are required: video, audio.
  795. this.htmlElement = {}; // DOM elements created by jPlayer
  796. this.html = {}; // In _init()'s this.desired code and setmedia(): Accessed via this[solution], where solution from this.solutions array.
  797. this.html.audio = {};
  798. this.html.video = {};
  799. this.aurora = {}; // In _init()'s this.desired code and setmedia(): Accessed via this[solution], where solution from this.solutions array.
  800. this.aurora.formats = [];
  801. this.aurora.properties = [];
  802. this.flash = {}; // In _init()'s this.desired code and setmedia(): Accessed via this[solution], where solution from this.solutions array.
  803. this.css = {};
  804. this.css.cs = {}; // Holds the css selector strings
  805. this.css.jq = {}; // Holds jQuery selectors. ie., $(css.cs.method)
  806. this.ancestorJq = []; // Holds jQuery selector of cssSelectorAncestor. Init would use $() instead of [], but it is only 1.4+
  807. this.options.volume = this._limitValue(this.options.volume, 0, 1); // Limit volume value's bounds.
  808. // Create the formats array, with prority based on the order of the supplied formats string
  809. $.each(this.options.supplied.toLowerCase().split(","), function(index1, value1) {
  810. var format = value1.replace(/^\s+|\s+$/g, ""); //trim
  811. if(self.format[format]) { // Check format is valid.
  812. var dupFound = false;
  813. $.each(self.formats, function(index2, value2) { // Check for duplicates
  814. if(format === value2) {
  815. dupFound = true;
  816. return false;
  817. }
  818. });
  819. if(!dupFound) {
  820. self.formats.push(format);
  821. }
  822. }
  823. });
  824. // Create the solutions array, with prority based on the order of the solution string
  825. $.each(this.options.solution.toLowerCase().split(","), function(index1, value1) {
  826. var solution = value1.replace(/^\s+|\s+$/g, ""); //trim
  827. if(self.solution[solution]) { // Check solution is valid.
  828. var dupFound = false;
  829. $.each(self.solutions, function(index2, value2) { // Check for duplicates
  830. if(solution === value2) {
  831. dupFound = true;
  832. return false;
  833. }
  834. });
  835. if(!dupFound) {
  836. self.solutions.push(solution);
  837. }
  838. }
  839. });
  840. // Create Aurora.js formats array
  841. $.each(this.options.auroraFormats.toLowerCase().split(","), function(index1, value1) {
  842. var format = value1.replace(/^\s+|\s+$/g, ""); //trim
  843. if(self.format[format]) { // Check format is valid.
  844. var dupFound = false;
  845. $.each(self.aurora.formats, function(index2, value2) { // Check for duplicates
  846. if(format === value2) {
  847. dupFound = true;
  848. return false;
  849. }
  850. });
  851. if(!dupFound) {
  852. self.aurora.formats.push(format);
  853. }
  854. }
  855. });
  856. this.internal.instance = "jp_" + this.count;
  857. this.instances[this.internal.instance] = this.element;
  858. // Check the jPlayer div has an id and create one if required. Important for Flash to know the unique id for comms.
  859. if(!this.element.attr("id")) {
  860. this.element.attr("id", this.options.idPrefix + "_jplayer_" + this.count);
  861. }
  862. this.internal.self = $.extend({}, {
  863. id: this.element.attr("id"),
  864. jq: this.element
  865. });
  866. this.internal.audio = $.extend({}, {
  867. id: this.options.idPrefix + "_audio_" + this.count,
  868. jq: undefined
  869. });
  870. this.internal.video = $.extend({}, {
  871. id: this.options.idPrefix + "_video_" + this.count,
  872. jq: undefined
  873. });
  874. this.internal.flash = $.extend({}, {
  875. id: this.options.idPrefix + "_flash_" + this.count,
  876. jq: undefined,
  877. swf: this.options.swfPath + (this.options.swfPath.toLowerCase().slice(-4) !== ".swf" ? (this.options.swfPath && this.options.swfPath.slice(-1) !== "/" ? "/" : "") + "jquery.jplayer.swf" : "")
  878. });
  879. this.internal.poster = $.extend({}, {
  880. id: this.options.idPrefix + "_poster_" + this.count,
  881. jq: undefined
  882. });
  883. // Register listeners defined in the constructor
  884. $.each($.jPlayer.event, function(eventName,eventType) {
  885. if(self.options[eventName] !== undefined) {
  886. self.element.bind(eventType + ".jPlayer", self.options[eventName]); // With .jPlayer namespace.
  887. 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.
  888. }
  889. });
  890. // Determine if we require solutions for audio, video or both media types.
  891. this.require.audio = false;
  892. this.require.video = false;
  893. $.each(this.formats, function(priority, format) {
  894. self.require[self.format[format].media] = true;
  895. });
  896. // Now required types are known, finish the options default settings.
  897. if(this.require.video) {
  898. this.options = $.extend(true, {},
  899. this.optionsVideo,
  900. this.options
  901. );
  902. } else {
  903. this.options = $.extend(true, {},
  904. this.optionsAudio,
  905. this.options
  906. );
  907. }
  908. this._setSize(); // update status and jPlayer element size
  909. // Determine the status for Blocklisted options.
  910. this.status.nativeVideoControls = this._uaBlocklist(this.options.nativeVideoControls);
  911. this.status.noFullWindow = this._uaBlocklist(this.options.noFullWindow);
  912. this.status.noVolume = this._uaBlocklist(this.options.noVolume);
  913. // Create event handlers if native fullscreen is supported
  914. if($.jPlayer.nativeFeatures.fullscreen.api.fullscreenEnabled) {
  915. this._fullscreenAddEventListeners();
  916. }
  917. // The native controls are only for video and are disabled when audio is also used.
  918. this._restrictNativeVideoControls();
  919. // Create the poster image.
  920. this.htmlElement.poster = document.createElement('img');
  921. this.htmlElement.poster.id = this.internal.poster.id;
  922. 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.
  923. if(!self.status.video || self.status.waitForPlay) {
  924. self.internal.poster.jq.show();
  925. }
  926. };
  927. this.element.append(this.htmlElement.poster);
  928. this.internal.poster.jq = $("#" + this.internal.poster.id);
  929. this.internal.poster.jq.css({'width': this.status.width, 'height': this.status.height});
  930. this.internal.poster.jq.hide();
  931. this.internal.poster.jq.bind("click.jPlayer", function() {
  932. self._trigger($.jPlayer.event.click);
  933. });
  934. // Generate the required media elements
  935. this.html.audio.available = false;
  936. if(this.require.audio) { // If a supplied format is audio
  937. this.htmlElement.audio = document.createElement('audio');
  938. this.htmlElement.audio.id = this.internal.audio.id;
  939. this.html.audio.available = !!this.htmlElement.audio.canPlayType && this._testCanPlayType(this.htmlElement.audio); // Test is for IE9 on Win Server 2008.
  940. }
  941. this.html.video.available = false;
  942. if(this.require.video) { // If a supplied format is video
  943. this.htmlElement.video = document.createElement('video');
  944. this.htmlElement.video.id = this.internal.video.id;
  945. this.html.video.available = !!this.htmlElement.video.canPlayType && this._testCanPlayType(this.htmlElement.video); // Test is for IE9 on Win Server 2008.
  946. }
  947. this.flash.available = this._checkForFlash(10.1);
  948. this.html.canPlay = {};
  949. this.aurora.canPlay = {};
  950. this.flash.canPlay = {};
  951. $.each(this.formats, function(priority, format) {
  952. self.html.canPlay[format] = self.html[self.format[format].media].available && "" !== self.htmlElement[self.format[format].media].canPlayType(self.format[format].codec);
  953. self.aurora.canPlay[format] = ($.inArray(format, self.aurora.formats) > -1);
  954. self.flash.canPlay[format] = self.format[format].flashCanPlay && self.flash.available;
  955. });
  956. this.html.desired = false;
  957. this.aurora.desired = false;
  958. this.flash.desired = false;
  959. $.each(this.solutions, function(solutionPriority, solution) {
  960. if(solutionPriority === 0) {
  961. self[solution].desired = true;
  962. } else {
  963. var audioCanPlay = false;
  964. var videoCanPlay = false;
  965. $.each(self.formats, function(formatPriority, format) {
  966. if(self[self.solutions[0]].canPlay[format]) { // The other solution can play
  967. if(self.format[format].media === 'video') {
  968. videoCanPlay = true;
  969. } else {
  970. audioCanPlay = true;
  971. }
  972. }
  973. });
  974. self[solution].desired = (self.require.audio && !audioCanPlay) || (self.require.video && !videoCanPlay);
  975. }
  976. });
  977. // This is what jPlayer will support, based on solution and supplied.
  978. this.html.support = {};
  979. this.aurora.support = {};
  980. this.flash.support = {};
  981. $.each(this.formats, function(priority, format) {
  982. self.html.support[format] = self.html.canPlay[format] && self.html.desired;
  983. self.aurora.support[format] = self.aurora.canPlay[format] && self.aurora.desired;
  984. self.flash.support[format] = self.flash.canPlay[format] && self.flash.desired;
  985. });
  986. // If jPlayer is supporting any format in a solution, then the solution is used.
  987. this.html.used = false;
  988. this.aurora.used = false;
  989. this.flash.used = false;
  990. $.each(this.solutions, function(solutionPriority, solution) {
  991. $.each(self.formats, function(formatPriority, format) {
  992. if(self[solution].support[format]) {
  993. self[solution].used = true;
  994. return false;
  995. }
  996. });
  997. });
  998. // Init solution active state and the event gates to false.
  999. this._resetActive();
  1000. this._resetGate();
  1001. // Set up the css selectors for the control and feedback entities.
  1002. this._cssSelectorAncestor(this.options.cssSelectorAncestor);
  1003. // If neither html nor aurora nor flash are being used by this browser, then media playback is not possible. Trigger an error event.
  1004. if(!(this.html.used || this.aurora.used || this.flash.used)) {
  1005. this._error( {
  1006. type: $.jPlayer.error.NO_SOLUTION,
  1007. context: "{solution:'" + this.options.solution + "', supplied:'" + this.options.supplied + "'}",
  1008. message: $.jPlayer.errorMsg.NO_SOLUTION,
  1009. hint: $.jPlayer.errorHint.NO_SOLUTION
  1010. });
  1011. if(this.css.jq.noSolution.length) {
  1012. this.css.jq.noSolution.show();
  1013. }
  1014. } else {
  1015. if(this.css.jq.noSolution.length) {
  1016. this.css.jq.noSolution.hide();
  1017. }
  1018. }
  1019. // Add the flash solution if it is being used.
  1020. if(this.flash.used) {
  1021. var htmlObj,
  1022. flashVars = 'jQuery=' + encodeURI(this.options.noConflict) + '&id=' + encodeURI(this.internal.self.id) + '&vol=' + this.options.volume + '&muted=' + this.options.muted;
  1023. // Code influenced by SWFObject 2.2: http://code.google.com/p/swfobject/
  1024. // Non IE browsers have an initial Flash size of 1 by 1 otherwise the wmode affected the Flash ready event.
  1025. if($.jPlayer.browser.msie && (Number($.jPlayer.browser.version) < 9 || $.jPlayer.browser.documentMode < 9)) {
  1026. var objStr = '<object id="' + this.internal.flash.id + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="0" height="0" tabindex="-1"></object>';
  1027. var paramStr = [
  1028. '<param name="movie" value="' + this.internal.flash.swf + '" />',
  1029. '<param name="FlashVars" value="' + flashVars + '" />',
  1030. '<param name="allowScriptAccess" value="always" />',
  1031. '<param name="bgcolor" value="' + this.options.backgroundColor + '" />',
  1032. '<param name="wmode" value="' + this.options.wmode + '" />'
  1033. ];
  1034. htmlObj = document.createElement(objStr);
  1035. for(var i=0; i < paramStr.length; i++) {
  1036. htmlObj.appendChild(document.createElement(paramStr[i]));
  1037. }
  1038. } else {
  1039. var createParam = function(el, n, v) {
  1040. var p = document.createElement("param");
  1041. p.setAttribute("name", n);
  1042. p.setAttribute("value", v);
  1043. el.appendChild(p);
  1044. };
  1045. htmlObj = document.createElement("object");
  1046. htmlObj.setAttribute("id", this.internal.flash.id);
  1047. htmlObj.setAttribute("name", this.internal.flash.id);
  1048. htmlObj.setAttribute("data", this.internal.flash.swf);
  1049. htmlObj.setAttribute("type", "application/x-shockwave-flash");
  1050. htmlObj.setAttribute("width", "1"); // Non-zero
  1051. htmlObj.setAttribute("height", "1"); // Non-zero
  1052. htmlObj.setAttribute("tabindex", "-1");
  1053. createParam(htmlObj, "flashvars", flashVars);
  1054. createParam(htmlObj, "allowscriptaccess", "always");
  1055. createParam(htmlObj, "bgcolor", this.options.backgroundColor);
  1056. createParam(htmlObj, "wmode", this.options.wmode);
  1057. }
  1058. this.element.append(htmlObj);
  1059. this.internal.flash.jq = $(htmlObj);
  1060. }
  1061. // Setup playbackRate ability before using _addHtmlEventListeners()
  1062. if(this.html.used && !this.flash.used) { // If only HTML
  1063. // Using the audio element capabilities for playbackRate. ie., Assuming video element is the same.
  1064. this.status.playbackRateEnabled = this._testPlaybackRate('audio');
  1065. } else {
  1066. this.status.playbackRateEnabled = false;
  1067. }
  1068. this._updatePlaybackRate();
  1069. // Add the HTML solution if being used.
  1070. if(this.html.used) {
  1071. // The HTML Audio handlers
  1072. if(this.html.audio.available) {
  1073. this._addHtmlEventListeners(this.htmlElement.audio, this.html.audio);
  1074. this.element.append(this.htmlElement.audio);
  1075. this.internal.audio.jq = $("#" + this.internal.audio.id);
  1076. }
  1077. // The HTML Video handlers
  1078. if(this.html.video.available) {
  1079. this._addHtmlEventListeners(this.htmlElement.video, this.html.video);
  1080. this.element.append(this.htmlElement.video);
  1081. this.internal.video.jq = $("#" + this.internal.video.id);
  1082. if(this.status.nativeVideoControls) {
  1083. this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height});
  1084. } else {
  1085. this.internal.video.jq.css({'width':'0px', 'height':'0px'}); // Using size 0x0 since a .hide() causes issues in iOS
  1086. }
  1087. this.internal.video.jq.bind("click.jPlayer", function() {
  1088. self._trigger($.jPlayer.event.click);
  1089. });
  1090. }
  1091. }
  1092. // Add the Aurora.js solution if being used.
  1093. if(this.aurora.used) {
  1094. // Aurora.js player need to be created for each media, see setMedia function.
  1095. }
  1096. // Create the bridge that emulates the HTML Media element on the jPlayer DIV
  1097. if( this.options.emulateHtml ) {
  1098. this._emulateHtmlBridge();
  1099. }
  1100. if((this.html.used || this.aurora.used) && !this.flash.used) { // If only HTML, then emulate flash ready() call after 100ms.
  1101. setTimeout( function() {
  1102. self.internal.ready = true;
  1103. self.version.flash = "n/a";
  1104. self._trigger($.jPlayer.event.repeat); // Trigger the repeat event so its handler can initialize itself with the loop option.
  1105. self._trigger($.jPlayer.event.ready);
  1106. }, 100);
  1107. }
  1108. // Initialize the interface components with the options.
  1109. this._updateNativeVideoControls();
  1110. // The other controls are now setup in _cssSelectorAncestor()
  1111. if(this.css.jq.videoPlay.length) {
  1112. this.css.jq.videoPlay.hide();
  1113. }
  1114. $.jPlayer.prototype.count++; // Change static variable via prototype.
  1115. },
  1116. destroy: function() {
  1117. // MJP: The background change remains. Would need to store the original to restore it correctly.
  1118. // MJP: The jPlayer element's size change remains.
  1119. // Clear the media to reset the GUI and stop any downloads. Streams on some browsers had persited. (Chrome)
  1120. this.clearMedia();
  1121. // Remove the size/sizeFull cssClass from the cssSelectorAncestor
  1122. this._removeUiClass();
  1123. // Remove the times from the GUI
  1124. if(this.css.jq.currentTime.length) {
  1125. this.css.jq.currentTime.text("");
  1126. }
  1127. if(this.css.jq.duration.length) {
  1128. this.css.jq.duration.text("");
  1129. }
  1130. // Remove any bindings from the interface controls.
  1131. $.each(this.css.jq, function(fn, jq) {
  1132. // Check selector is valid before trying to execute method.
  1133. if(jq.length) {
  1134. jq.unbind(".jPlayer");
  1135. }
  1136. });
  1137. // Remove the click handlers for $.jPlayer.event.click
  1138. this.internal.poster.jq.unbind(".jPlayer");
  1139. if(this.internal.video.jq) {
  1140. this.internal.video.jq.unbind(".jPlayer");
  1141. }
  1142. // Remove the fullscreen event handlers
  1143. this._fullscreenRemoveEventListeners();
  1144. // Remove key bindings
  1145. if(this === $.jPlayer.focus) {
  1146. $.jPlayer.focus = null;
  1147. }
  1148. // Destroy the HTML bridge.
  1149. if(this.options.emulateHtml) {
  1150. this._destroyHtmlBridge();
  1151. }
  1152. this.element.removeData("jPlayer"); // Remove jPlayer data
  1153. this.element.unbind(".jPlayer"); // Remove all event handlers created by the jPlayer constructor
  1154. this.element.empty(); // Remove the inserted child elements
  1155. delete this.instances[this.internal.instance]; // Clear the instance on the static instance object
  1156. },
  1157. destroyRemoved: function() { // Destroy any instances that have gone away.
  1158. var self = this;
  1159. $.each(this.instances, function(i, element) {
  1160. if(self.element !== element) { // Do not destroy this instance.
  1161. if(!element.data("jPlayer")) { // Check that element is a real jPlayer.
  1162. element.jPlayer("destroy");
  1163. delete self.instances[i];
  1164. }
  1165. }
  1166. });
  1167. },
  1168. enable: function() { // Plan to implement
  1169. // options.disabled = false
  1170. },
  1171. disable: function () { // Plan to implement
  1172. // options.disabled = true
  1173. },
  1174. _testCanPlayType: function(elem) {
  1175. // IE9 on Win Server 2008 did not implement canPlayType(), but it has the property.
  1176. try {
  1177. elem.canPlayType(this.format.mp3.codec); // The type is irrelevant.
  1178. return true;
  1179. } catch(err) {
  1180. return false;
  1181. }
  1182. },
  1183. _testPlaybackRate: function(type) {
  1184. // type: String 'audio' or 'video'
  1185. var el, rate = 0.5;
  1186. type = typeof type === 'string' ? type : 'audio';
  1187. el = document.createElement(type);
  1188. // Wrapping in a try/catch, just in case older HTML5 browsers throw and error.
  1189. try {
  1190. if('playbackRate' in el) {
  1191. el.playbackRate = rate;
  1192. return el.playbackRate === rate;
  1193. } else {
  1194. return false;
  1195. }
  1196. } catch(err) {
  1197. return false;
  1198. }
  1199. },
  1200. _uaBlocklist: function(list) {
  1201. // list : object with properties that are all regular expressions. Property names are irrelevant.
  1202. // Returns true if the user agent is matched in list.
  1203. var ua = navigator.userAgent.toLowerCase(),
  1204. block = false;
  1205. $.each(list, function(p, re) {
  1206. if(re && re.test(ua)) {
  1207. block = true;
  1208. return false; // exit $.each.
  1209. }
  1210. });
  1211. return block;
  1212. },
  1213. _restrictNativeVideoControls: function() {
  1214. // Fallback to noFullWindow when nativeVideoControls is true and audio media is being used. Affects when both media types are used.
  1215. if(this.require.audio) {
  1216. if(this.status.nativeVideoControls) {
  1217. this.status.nativeVideoControls = false;
  1218. this.status.noFullWindow = true;
  1219. }
  1220. }
  1221. },
  1222. _updateNativeVideoControls: function() {
  1223. if(this.html.video.available && this.html.used) {
  1224. // Turn the HTML Video controls on/off
  1225. this.htmlElement.video.controls = this.status.nativeVideoControls;
  1226. // Show/hide the jPlayer GUI.
  1227. this._updateAutohide();
  1228. // 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.
  1229. if(this.status.nativeVideoControls && this.require.video) {
  1230. this.internal.poster.jq.hide();
  1231. this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height});
  1232. } else if(this.status.waitForPlay && this.status.video) {
  1233. this.internal.poster.jq.show();
  1234. this.internal.video.jq.css({'width': '0px', 'height': '0px'});
  1235. }
  1236. }
  1237. },
  1238. _addHtmlEventListeners: function(mediaElement, entity) {
  1239. var self = this;
  1240. mediaElement.preload = this.options.preload;
  1241. mediaElement.muted = this.options.muted;
  1242. mediaElement.volume = this.options.volume;
  1243. if(this.status.playbackRateEnabled) {
  1244. mediaElement.defaultPlaybackRate = this.options.defaultPlaybackRate;
  1245. mediaElement.playbackRate = this.options.playbackRate;
  1246. }
  1247. // Create the event listeners
  1248. // Only want the active entity to affect jPlayer and bubble events.
  1249. // Using entity.gate so that object is referenced and gate property always current
  1250. mediaElement.addEventListener("progress", function() {
  1251. if(entity.gate) {
  1252. if(self.internal.cmdsIgnored && this.readyState > 0) { // Detect iOS executed the command
  1253. self.internal.cmdsIgnored = false;
  1254. }
  1255. self._getHtmlStatus(mediaElement);
  1256. self._updateInterface();
  1257. self._trigger($.jPlayer.event.progress);
  1258. }
  1259. }, false);
  1260. mediaElement.addEventListener("loadeddata", function() {
  1261. if(entity.gate) {
  1262. self.androidFix.setMedia = false; // Disable the fix after the first progress event.
  1263. if(self.androidFix.play) { // Play Android audio - performing the fix.
  1264. self.androidFix.play = false;
  1265. self.play(self.androidFix.time);
  1266. }
  1267. if(self.androidFix.pause) { // Pause Android audio at time - performing the fix.
  1268. self.androidFix.pause = false;
  1269. self.pause(self.androidFix.time);
  1270. }
  1271. self._trigger($.jPlayer.event.loadeddata);
  1272. }
  1273. }, false);
  1274. mediaElement.addEventListener("timeupdate", function() {
  1275. if(entity.gate) {
  1276. self._getHtmlStatus(mediaElement);
  1277. self._updateInterface();
  1278. self._trigger($.jPlayer.event.timeupdate);
  1279. }
  1280. }, false);
  1281. mediaElement.addEventListener("durationchange", function() {
  1282. if(entity.gate) {
  1283. self._getHtmlStatus(mediaElement);
  1284. self._updateInterface();
  1285. self._trigger($.jPlayer.event.durationchange);
  1286. }
  1287. }, false);
  1288. mediaElement.addEventListener("play", function() {
  1289. if(entity.gate) {
  1290. self._updateButtons(true);
  1291. self._html_checkWaitForPlay(); // So the native controls update this variable and puts the hidden interface in the correct state. Affects toggling native controls.
  1292. self._trigger($.jPlayer.event.play);
  1293. }
  1294. }, false);
  1295. mediaElement.addEventListener("playing", function() {
  1296. if(entity.gate) {
  1297. self._updateButtons(true);
  1298. self._seeked();
  1299. self._trigger($.jPlayer.event.playing);
  1300. }
  1301. }, false);
  1302. mediaElement.addEventListener("pause", function() {
  1303. if(entity.gate) {
  1304. self._updateButtons(false);
  1305. self._trigger($.jPlayer.event.pause);
  1306. }
  1307. }, false);
  1308. mediaElement.addEventListener("waiting", function() {
  1309. if(entity.gate) {
  1310. self._seeking();
  1311. self._trigger($.jPlayer.event.waiting);
  1312. }
  1313. }, false);
  1314. mediaElement.addEventListener("seeking", function() {
  1315. if(entity.gate) {
  1316. self._seeking();
  1317. self._trigger($.jPlayer.event.seeking);
  1318. }
  1319. }, false);
  1320. mediaElement.addEventListener("seeked", function() {
  1321. if(entity.gate) {
  1322. self._seeked();
  1323. self._trigger($.jPlayer.event.seeked);
  1324. }
  1325. }, false);
  1326. mediaElement.addEventListener("volumechange", function() {
  1327. if(entity.gate) {
  1328. // Read the values back from the element as the Blackberry PlayBook shares the volume with the physical buttons master volume control.
  1329. // However, when tested 6th July 2011, those buttons do not generate an event. The physical play/pause button does though.
  1330. self.options.volume = mediaElement.volume;
  1331. self.options.muted = mediaElement.muted;
  1332. self._updateMute();
  1333. self._updateVolume();
  1334. self._trigger($.jPlayer.event.volumechange);
  1335. }
  1336. }, false);
  1337. mediaElement.addEventListener("ratechange", function() {
  1338. if(entity.gate) {
  1339. self.options.defaultPlaybackRate = mediaElement.defaultPlaybackRate;
  1340. self.options.playbackRate = mediaElement.playbackRate;
  1341. self._updatePlaybackRate();
  1342. self._trigger($.jPlayer.event.ratechange);
  1343. }
  1344. }, false);
  1345. 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.
  1346. if(entity.gate) {
  1347. self._seeked();
  1348. self._trigger($.jPlayer.event.suspend);
  1349. }
  1350. }, false);
  1351. mediaElement.addEventListener("ended", function() {
  1352. if(entity.gate) {
  1353. // Order of the next few commands are important. Change the time and then pause.
  1354. // Solves a bug in Firefox, where issuing pause 1st causes the media to play from the start. ie., The pause is ignored.
  1355. 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.
  1356. 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.)
  1357. }
  1358. 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.
  1359. self._updateButtons(false);
  1360. self._getHtmlStatus(mediaElement, true); // With override true. Otherwise Chrome leaves progress at full.
  1361. self._updateInterface();
  1362. self._trigger($.jPlayer.event.ended);
  1363. }
  1364. }, false);
  1365. mediaElement.addEventListener("error", function() {
  1366. if(entity.gate) {
  1367. self._updateButtons(false);
  1368. self._seeked();
  1369. if(self.status.srcSet) { // Deals with case of clearMedia() causing an error event.
  1370. clearTimeout(self.internal.htmlDlyCmdId); // Clears any delayed commands used in the HTML solution.
  1371. self.status.waitForLoad = true; // Allows the load operation to try again.
  1372. self.status.waitForPlay = true; // Reset since a play was captured.
  1373. if(self.status.video && !self.status.nativeVideoControls) {
  1374. self.internal.video.jq.css({'width':'0px', 'height':'0px'});
  1375. }
  1376. if(self._validString(self.status.media.poster) && !self.status.nativeVideoControls) {
  1377. self.internal.poster.jq.show();
  1378. }
  1379. if(self.css.jq.videoPlay.length) {
  1380. self.css.jq.videoPlay.show();
  1381. }
  1382. self._error( {
  1383. type: $.jPlayer.error.URL,
  1384. context: self.status.src, // this.src shows absolute urls. Want context to show the url given.
  1385. message: $.jPlayer.errorMsg.URL,
  1386. hint: $.jPlayer.errorHint.URL
  1387. });
  1388. }
  1389. }
  1390. }, false);
  1391. // Create all the other event listeners that bubble up to a jPlayer event from html, without being used by jPlayer.
  1392. $.each($.jPlayer.htmlEvent, function(i, eventType) {
  1393. mediaElement.addEventListener(this, function() {
  1394. if(entity.gate) {
  1395. self._trigger($.jPlayer.event[eventType]);
  1396. }
  1397. }, false);
  1398. });
  1399. },
  1400. _addAuroraEventListeners : function(player, entity) {
  1401. var self = this;
  1402. //player.preload = this.options.preload;
  1403. //player.muted = this.options.muted;
  1404. player.volume = this.options.volume * 100;
  1405. // Create the event listeners
  1406. // Only want the active entity to affect jPlayer and bubble events.
  1407. // Using entity.gate so that object is referenced and gate property always current
  1408. player.on("progress", function() {
  1409. if(entity.gate) {
  1410. if(self.internal.cmdsIgnored && this.readyState > 0) { // Detect iOS executed the command
  1411. self.internal.cmdsIgnored = false;
  1412. }
  1413. self._getAuroraStatus(player);
  1414. self._updateInterface();
  1415. self._trigger($.jPlayer.event.progress);
  1416. // Progress with song duration, we estimate timeupdate need to be triggered too.
  1417. if (player.duration > 0) {
  1418. self._trigger($.jPlayer.event.timeupdate);
  1419. }
  1420. }
  1421. }, false);
  1422. player.on("ready", function() {
  1423. if(entity.gate) {
  1424. self._trigger($.jPlayer.event.loadeddata);
  1425. }
  1426. }, false);
  1427. player.on("duration", function() {
  1428. if(entity.gate) {
  1429. self._getAuroraStatus(player);
  1430. self._updateInterface();
  1431. self._trigger($.jPlayer.event.durationchange);
  1432. }
  1433. }, false);
  1434. player.on("end", function() {
  1435. if(entity.gate) {
  1436. // Order of the next few commands are important. Change the time and then pause.
  1437. self._updateButtons(false);
  1438. self._getAuroraStatus(player, true);
  1439. self._updateInterface();
  1440. self._trigger($.jPlayer.event.ended);
  1441. }
  1442. }, false);
  1443. player.on("error", function() {
  1444. if(entity.gate) {
  1445. self._updateButtons(false);
  1446. self._seeked();
  1447. if(self.status.srcSet) { // Deals with case of clearMedia() causing an error event.
  1448. self.status.waitForLoad = true; // Allows the load operation to try again.
  1449. self.status.waitForPlay = true; // Reset since a play was captured.
  1450. if(self.status.video && !self.status.nativeVideoControls) {
  1451. self.internal.video.jq.css({'width':'0px', 'height':'0px'});
  1452. }
  1453. if(self._validString(self.status.media.poster) && !self.status.nativeVideoControls) {
  1454. self.internal.poster.jq.show();
  1455. }
  1456. if(self.css.jq.videoPlay.length) {
  1457. self.css.jq.videoPlay.show();
  1458. }
  1459. self._error( {
  1460. type: $.jPlayer.error.URL,
  1461. context: self.status.src, // this.src shows absolute urls. Want context to show the url given.
  1462. message: $.jPlayer.errorMsg.URL,
  1463. hint: $.jPlayer.errorHint.URL
  1464. });
  1465. }
  1466. }
  1467. }, false);
  1468. },
  1469. _getHtmlStatus: function(media, override) {
  1470. var ct = 0, cpa = 0, sp = 0, cpr = 0;
  1471. // Fixes the duration bug in iOS, where the durationchange event occurs when media.duration is not always correct.
  1472. // Fixes the initial duration bug in BB OS7, where the media.duration is infinity and displays as NaN:NaN due to Date() using inifity.
  1473. if(isFinite(media.duration)) {
  1474. this.status.duration = media.duration;
  1475. }
  1476. ct = media.currentTime;
  1477. cpa = (this.status.duration > 0) ? 100 * ct / this.status.duration : 0;
  1478. if((typeof media.seekable === "object") && (media.seekable.length > 0)) {
  1479. sp = (this.status.duration > 0) ? 100 * media.seekable.end(media.seekable.length-1) / this.status.duration : 100;
  1480. cpr = (this.status.duration > 0) ? 100 * media.currentTime / media.seekable.end(media.seekable.length-1) : 0; // Duration conditional for iOS duration bug. ie., seekable.end is a NaN in that case.
  1481. } else {
  1482. sp = 100;
  1483. cpr = cpa;
  1484. }
  1485. if(override) {
  1486. ct = 0;
  1487. cpr = 0;
  1488. cpa = 0;
  1489. }
  1490. this.status.seekPercent = sp;
  1491. this.status.currentPercentRelative = cpr;
  1492. this.status.currentPercentAbsolute = cpa;
  1493. this.status.currentTime = ct;
  1494. this.status.remaining = this.status.duration - this.status.currentTime;
  1495. this.status.videoWidth = media.videoWidth;
  1496. this.status.videoHeight = media.videoHeight;
  1497. this.status.readyState = media.readyState;
  1498. this.status.networkState = media.networkState;
  1499. this.status.playbackRate = media.playbackRate;
  1500. this.status.ended = media.ended;
  1501. },
  1502. _getAuroraStatus: function(player, override) {
  1503. var ct = 0, cpa = 0, sp = 0, cpr = 0;
  1504. this.status.duration = player.duration / 1000;
  1505. ct = player.currentTime / 1000;
  1506. cpa = (this.status.duration > 0) ? 100 * ct / this.status.duration : 0;
  1507. if(player.buffered > 0) {
  1508. sp = (this.status.duration > 0) ? (player.buffered * this.status.duration) / this.status.duration : 100;
  1509. cpr = (this.status.duration > 0) ? ct / (player.buffered * this.status.duration) : 0;
  1510. } else {
  1511. sp = 100;
  1512. cpr = cpa;
  1513. }
  1514. if(override) {
  1515. ct = 0;
  1516. cpr = 0;
  1517. cpa = 0;
  1518. }
  1519. this.status.seekPercent = sp;
  1520. this.status.currentPercentRelative = cpr;
  1521. this.status.currentPercentAbsolute = cpa;
  1522. this.status.currentTime = ct;
  1523. this.status.remaining = this.status.duration - this.status.currentTime;
  1524. this.status.readyState = 4; // status.readyState;
  1525. this.status.networkState = 0; // status.networkState;
  1526. this.status.playbackRate = 1; // status.playbackRate;
  1527. this.status.ended = false; // status.ended;
  1528. },
  1529. _resetStatus: function() {
  1530. this.status = $.extend({}, this.status, $.jPlayer.prototype.status); // Maintains the status properties that persist through a reset.
  1531. },
  1532. _trigger: function(eventType, error, warning) { // eventType always valid as called using $.jPlayer.event.eventType
  1533. var event = $.Event(eventType);
  1534. event.jPlayer = {};
  1535. event.jPlayer.version = $.extend({}, this.version);
  1536. event.jPlayer.options = $.extend(true, {}, this.options); // Deep copy
  1537. event.jPlayer.status = $.extend(true, {}, this.status); // Deep copy
  1538. event.jPlayer.html = $.extend(true, {}, this.html); // Deep copy
  1539. event.jPlayer.aurora = $.extend(true, {}, this.aurora); // Deep copy
  1540. event.jPlayer.flash = $.extend(true, {}, this.flash); // Deep copy
  1541. if(error) {
  1542. event.jPlayer.error = $.extend({}, error);
  1543. }
  1544. if(warning) {
  1545. event.jPlayer.warning = $.extend({}, warning);
  1546. }
  1547. this.element.trigger(event);
  1548. },
  1549. jPlayerFlashEvent: function(eventType, status) { // Called from Flash
  1550. if(eventType === $.jPlayer.event.ready) {
  1551. if(!this.internal.ready) {
  1552. this.internal.ready = true;
  1553. 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.
  1554. this.version.flash = status.version;
  1555. if(this.version.needFlash !== this.version.flash) {
  1556. this._error( {
  1557. type: $.jPlayer.error.VERSION,
  1558. context: this.version.flash,
  1559. message: $.jPlayer.errorMsg.VERSION + this.version.flash,
  1560. hint: $.jPlayer.errorHint.VERSION
  1561. });
  1562. }
  1563. this._trigger($.jPlayer.event.repeat); // Trigger the repeat event so its handler can initialize itself with the loop option.
  1564. this._trigger(eventType);
  1565. } else {
  1566. // This condition occurs if the Flash is hidden and then shown again.
  1567. // Firefox also reloads the Flash if the CSS position changes. position:fixed is used for full screen.
  1568. // Only do this if the Flash is the solution being used at the moment. Affects Media players where both solution may be being used.
  1569. if(this.flash.gate) {
  1570. // Send the current status to the Flash now that it is ready (available) again.
  1571. if(this.status.srcSet) {
  1572. // Need to read original status before issuing the setMedia command.
  1573. var currentTime = this.status.currentTime,
  1574. paused = this.status.paused;
  1575. this.setMedia(this.status.media);
  1576. this.volumeWorker(this.options.volume);
  1577. if(currentTime > 0) {
  1578. if(paused) {
  1579. this.pause(currentTime);
  1580. } else {
  1581. this.play(currentTime);
  1582. }
  1583. }
  1584. }
  1585. this._trigger($.jPlayer.event.flashreset);
  1586. }
  1587. }
  1588. }
  1589. if(this.flash.gate) {
  1590. switch(eventType) {
  1591. case $.jPlayer.event.progress:
  1592. this._getFlashStatus(status);
  1593. this._updateInterface();
  1594. this._trigger(eventType);
  1595. break;
  1596. case $.jPlayer.event.timeupdate:
  1597. this._getFlashStatus(status);
  1598. this._updateInterface();
  1599. this._trigger(eventType);
  1600. break;
  1601. case $.jPlayer.event.play:
  1602. this._seeked();
  1603. this._updateButtons(true);
  1604. this._trigger(eventType);
  1605. break;
  1606. case $.jPlayer.event.pause:
  1607. this._updateButtons(false);
  1608. this._trigger(eventType);
  1609. break;
  1610. case $.jPlayer.event.ended:
  1611. this._updateButtons(false);
  1612. this._trigger(eventType);
  1613. break;
  1614. case $.jPlayer.event.click:
  1615. this._trigger(eventType); // This could be dealt with by the default
  1616. break;
  1617. case $.jPlayer.event.error:
  1618. this.status.waitForLoad = true; // Allows the load operation to try again.
  1619. this.status.waitForPlay = true; // Reset since a play was captured.
  1620. if(this.status.video) {
  1621. this.internal.flash.jq.css({'width':'0px', 'height':'0px'});
  1622. }
  1623. if(this._validString(this.status.media.poster)) {
  1624. this.internal.poster.jq.show();
  1625. }
  1626. if(this.css.jq.videoPlay.length && this.status.video) {
  1627. this.css.jq.videoPlay.show();
  1628. }
  1629. if(this.status.video) { // Set up for another try. Execute before error event.
  1630. this._flash_setVideo(this.status.media);
  1631. } else {
  1632. this._flash_setAudio(this.status.media);
  1633. }
  1634. this._updateButtons(false);
  1635. this._error( {
  1636. type: $.jPlayer.error.URL,
  1637. context:status.src,
  1638. message: $.jPlayer.errorMsg.URL,
  1639. hint: $.jPlayer.errorHint.URL
  1640. });
  1641. break;
  1642. case $.jPlayer.event.seeking:
  1643. this._seeking();
  1644. this._trigger(eventType);
  1645. break;
  1646. case $.jPlayer.event.seeked:
  1647. this._seeked();
  1648. this._trigger(eventType);
  1649. break;
  1650. case $.jPlayer.event.ready:
  1651. // The ready event is handled outside the switch statement.
  1652. // Captured here otherwise 2 ready events would be generated if the ready event handler used setMedia.
  1653. break;
  1654. default:
  1655. this._trigger(eventType);
  1656. }
  1657. }
  1658. return false;
  1659. },
  1660. _getFlashStatus: function(status) {
  1661. this.status.seekPercent = status.seekPercent;
  1662. this.status.currentPercentRelative = status.currentPercentRelative;
  1663. this.status.currentPercentAbsolute = status.currentPercentAbsolute;
  1664. this.status.currentTime = status.currentTime;
  1665. this.status.duration = status.duration;
  1666. this.status.remaining = status.duration - status.currentTime;
  1667. this.status.videoWidth = status.videoWidth;
  1668. this.status.videoHeight = status.videoHeight;
  1669. // The Flash does not generate this information in this release
  1670. this.status.readyState = 4; // status.readyState;
  1671. this.status.networkState = 0; // status.networkState;
  1672. this.status.playbackRate = 1; // status.playbackRate;
  1673. this.status.ended = false; // status.ended;
  1674. },
  1675. _updateButtons: function(playing) {
  1676. if(playing === undefined) {
  1677. playing = !this.status.paused;
  1678. } else {
  1679. this.status.paused = !playing;
  1680. }
  1681. // Apply the state classes. (For the useStateClassSkin:true option)
  1682. if(playing) {
  1683. this.addStateClass('playing');
  1684. } else {
  1685. this.removeStateClass('playing');
  1686. }
  1687. if(!this.status.noFullWindow && this.options.fullWindow) {
  1688. this.addStateClass('fullScreen');
  1689. } else {
  1690. this.removeStateClass('fullScreen');
  1691. }
  1692. if(this.options.loop) {
  1693. this.addStateClass('looped');
  1694. } else {
  1695. this.removeStateClass('looped');
  1696. }
  1697. // Toggle the GUI element pairs. (For the useStateClassSkin:false option)
  1698. if(this.css.jq.play.length && this.css.jq.pause.length) {
  1699. if(playing) {
  1700. this.css.jq.play.hide();
  1701. this.css.jq.pause.show();
  1702. } else {
  1703. this.css.jq.play.show();
  1704. this.css.jq.pause.hide();
  1705. }
  1706. }
  1707. if(this.css.jq.restoreScreen.length && this.css.jq.fullScreen.length) {
  1708. if(this.status.noFullWindow) {
  1709. this.css.jq.fullScreen.hide();
  1710. this.css.jq.restoreScreen.hide();
  1711. } else if(this.options.fullWindow) {
  1712. this.css.jq.fullScreen.hide();
  1713. this.css.jq.restoreScreen.show();
  1714. } else {
  1715. this.css.jq.fullScreen.show();
  1716. this.css.jq.restoreScreen.hide();
  1717. }
  1718. }
  1719. if(this.css.jq.repeat.length && this.css.jq.repeatOff.length) {
  1720. if(this.options.loop) {
  1721. this.css.jq.repeat.hide();
  1722. this.css.jq.repeatOff.show();
  1723. } else {
  1724. this.css.jq.repeat.show();
  1725. this.css.jq.repeatOff.hide();
  1726. }
  1727. }
  1728. },
  1729. _updateInterface: function() {
  1730. if(this.css.jq.seekBar.length) {
  1731. this.css.jq.seekBar.width(this.status.seekPercent+"%");
  1732. }
  1733. if(this.css.jq.playBar.length) {
  1734. if(this.options.smoothPlayBar) {
  1735. this.css.jq.playBar.stop().animate({
  1736. width: this.status.currentPercentAbsolute+"%"
  1737. }, 250, "linear");
  1738. } else {
  1739. this.css.jq.playBar.width(this.status.currentPercentRelative+"%");
  1740. }
  1741. }
  1742. var currentTimeText = '';
  1743. if(this.css.jq.currentTime.length) {
  1744. currentTimeText = this._convertTime(this.status.currentTime);
  1745. if(currentTimeText !== this.css.jq.currentTime.text()) {
  1746. this.css.jq.currentTime.text(this._convertTime(this.status.currentTime));
  1747. }
  1748. }
  1749. var durationText = '',
  1750. duration = this.status.duration,
  1751. remaining = this.status.remaining;
  1752. if(this.css.jq.duration.length) {
  1753. if(typeof this.status.media.duration === 'string') {
  1754. durationText = this.status.media.duration;
  1755. } else {
  1756. if(typeof this.status.media.duration === 'number') {
  1757. duration = this.status.media.duration;
  1758. remaining = duration - this.status.currentTime;
  1759. }
  1760. if(this.options.remainingDuration) {
  1761. durationText = (remaining > 0 ? '-' : '') + this._convertTime(remaining);
  1762. } else {
  1763. durationText = this._convertTime(duration);
  1764. }
  1765. }
  1766. if(durationText !== this.css.jq.duration.text()) {
  1767. this.css.jq.duration.text(durationText);
  1768. }
  1769. }
  1770. },
  1771. _convertTime: ConvertTime.prototype.time,
  1772. _seeking: function() {
  1773. if(this.css.jq.seekBar.length) {
  1774. this.css.jq.seekBar.addClass("jp-seeking-bg");
  1775. }
  1776. this.addStateClass('seeking');
  1777. },
  1778. _seeked: function() {
  1779. if(this.css.jq.seekBar.length) {
  1780. this.css.jq.seekBar.removeClass("jp-seeking-bg");
  1781. }
  1782. this.removeStateClass('seeking');
  1783. },
  1784. _resetGate: function() {
  1785. this.html.audio.gate = false;
  1786. this.html.video.gate = false;
  1787. this.aurora.gate = false;
  1788. this.flash.gate = false;
  1789. },
  1790. _resetActive: function() {
  1791. this.html.active = false;
  1792. this.aurora.active = false;
  1793. this.flash.active = false;
  1794. },
  1795. _escapeHtml: function(s) {
  1796. return s.split('&').join('&amp;').split('<').join('&lt;').split('>').join('&gt;').split('"').join('&quot;');
  1797. },
  1798. _qualifyURL: function(url) {
  1799. var el = document.createElement('div');
  1800. el.innerHTML= '<a href="' + this._escapeHtml(url) + '">x</a>';
  1801. return el.firstChild.href;
  1802. },
  1803. _absoluteMediaUrls: function(media) {
  1804. var self = this;
  1805. $.each(media, function(type, url) {
  1806. if(url && self.format[type] && url.substr(0, 5) !== "data:") {
  1807. media[type] = self._qualifyURL(url);
  1808. }
  1809. });
  1810. return media;
  1811. },
  1812. addStateClass: function(state) {
  1813. if(this.ancestorJq.length) {
  1814. this.ancestorJq.addClass(this.options.stateClass[state]);
  1815. }
  1816. },
  1817. removeStateClass: function(state) {
  1818. if(this.ancestorJq.length) {
  1819. this.ancestorJq.removeClass(this.options.stateClass[state]);
  1820. }
  1821. },
  1822. setMedia: function(media) {
  1823. /* media[format] = String: URL of format. Must contain all of the supplied option's video or audio formats.
  1824. * media.poster = String: Video poster URL.
  1825. * media.track = Array: Of objects defining the track element: kind, src, srclang, label, def.
  1826. * media.stream = Boolean: * NOT IMPLEMENTED * Designating actual media streams. ie., "false/undefined" for files. Plan to refresh the flash every so often.
  1827. */
  1828. var self = this,
  1829. supported = false,
  1830. 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.
  1831. this._resetMedia();
  1832. this._resetGate();
  1833. this._resetActive();
  1834. // Clear the Android Fix.
  1835. this.androidFix.setMedia = false;
  1836. this.androidFix.play = false;
  1837. this.androidFix.pause = false;
  1838. // Convert all media URLs to absolute URLs.
  1839. media = this._absoluteMediaUrls(media);
  1840. $.each(this.formats, function(formatPriority, format) {
  1841. var isVideo = self.format[format].media === 'video';
  1842. $.each(self.solutions, function(solutionPriority, solution) {
  1843. if(self[solution].support[format] && self._validString(media[format])) { // Format supported in solution and url given for format.
  1844. var isHtml = solution === 'html';
  1845. var isAurora = solution === 'aurora';
  1846. if(isVideo) {
  1847. if(isHtml) {
  1848. self.html.video.gate = true;
  1849. self._html_setVideo(media);
  1850. self.html.active = true;
  1851. } else {
  1852. self.flash.gate = true;
  1853. self._flash_setVideo(media);
  1854. self.flash.active = true;
  1855. }
  1856. if(self.css.jq.videoPlay.length) {
  1857. self.css.jq.videoPlay.show();
  1858. }
  1859. self.status.video = true;
  1860. } else {
  1861. if(isHtml) {
  1862. self.html.audio.gate = true;
  1863. self._html_setAudio(media);
  1864. self.html.active = true;
  1865. // Setup the Android Fix - Only for HTML audio.
  1866. if($.jPlayer.platform.android) {
  1867. self.androidFix.setMedia = true;
  1868. }
  1869. } else if(isAurora) {
  1870. self.aurora.gate = true;
  1871. self._aurora_setAudio(media);
  1872. self.aurora.active = true;
  1873. } else {
  1874. self.flash.gate = true;
  1875. self._flash_setAudio(media);
  1876. self.flash.active = true;
  1877. }
  1878. if(self.css.jq.videoPlay.length) {
  1879. self.css.jq.videoPlay.hide();
  1880. }
  1881. self.status.video = false;
  1882. }
  1883. supported = true;
  1884. return false; // Exit $.each
  1885. }
  1886. });
  1887. if(supported) {
  1888. return false; // Exit $.each
  1889. }
  1890. });
  1891. if(supported) {
  1892. if(!(this.status.nativeVideoControls && this.html.video.gate)) {
  1893. // Set poster IMG if native video controls are not being used
  1894. // Note: With IE the IMG onload event occurs immediately when cached.
  1895. // Note: Poster hidden by default in _resetMedia()
  1896. if(this._validString(media.poster)) {
  1897. if(posterChanged) { // Since some browsers do not generate img onload event.
  1898. this.htmlElement.poster.src = media.poster;
  1899. } else {
  1900. this.internal.poster.jq.show();
  1901. }
  1902. }
  1903. }
  1904. if(typeof media.title === 'string') {
  1905. if(this.css.jq.title.length) {
  1906. this.css.jq.title.html(media.title);
  1907. }
  1908. if(this.htmlElement.audio) {
  1909. this.htmlElement.audio.setAttribute('title', media.title);
  1910. }
  1911. if(this.htmlElement.video) {
  1912. this.htmlElement.video.setAttribute('title', media.title);
  1913. }
  1914. }
  1915. this.status.srcSet = true;
  1916. this.status.media = $.extend({}, media);
  1917. this._updateButtons(false);
  1918. this._updateInterface();
  1919. this._trigger($.jPlayer.event.setmedia);
  1920. } else { // jPlayer cannot support any formats provided in this browser
  1921. // Send an error event
  1922. this._error( {
  1923. type: $.jPlayer.error.NO_SUPPORT,
  1924. context: "{supplied:'" + this.options.supplied + "'}",
  1925. message: $.jPlayer.errorMsg.NO_SUPPORT,
  1926. hint: $.jPlayer.errorHint.NO_SUPPORT
  1927. });
  1928. }
  1929. },
  1930. _resetMedia: function() {
  1931. this._resetStatus();
  1932. this._updateButtons(false);
  1933. this._updateInterface();
  1934. this._seeked();
  1935. this.internal.poster.jq.hide();
  1936. clearTimeout(this.internal.htmlDlyCmdId);
  1937. if(this.html.active) {
  1938. this._html_resetMedia();
  1939. } else if(this.aurora.active) {
  1940. this._aurora_resetMedia();
  1941. } else if(this.flash.active) {
  1942. this._flash_resetMedia();
  1943. }
  1944. },
  1945. clearMedia: function() {
  1946. this._resetMedia();
  1947. if(this.html.active) {
  1948. this._html_clearMedia();
  1949. } else if(this.aurora.active) {
  1950. this._aurora_clearMedia();
  1951. } else if(this.flash.active) {
  1952. this._flash_clearMedia();
  1953. }
  1954. this._resetGate();
  1955. this._resetActive();
  1956. },
  1957. load: function() {
  1958. if(this.status.srcSet) {
  1959. if(this.html.active) {
  1960. this._html_load();
  1961. } else if(this.aurora.active) {
  1962. this._aurora_load();
  1963. } else if(this.flash.active) {
  1964. this._flash_load();
  1965. }
  1966. } else {
  1967. this._urlNotSetError("load");
  1968. }
  1969. },
  1970. focus: function() {
  1971. if(this.options.keyEnabled) {
  1972. $.jPlayer.focus = this;
  1973. }
  1974. },
  1975. play: function(time) {
  1976. var guiAction = typeof time === "object"; // Flags GUI click events so we know this was not a direct command, but an action taken by the user on the GUI.
  1977. if(guiAction && this.options.useStateClassSkin && !this.status.paused) {
  1978. this.pause(time); // The time would be the click event, but passing it over so info is not lost.
  1979. } else {
  1980. time = (typeof time === "number") ? time : NaN; // Remove jQuery event from click handler
  1981. if(this.status.srcSet) {
  1982. this.focus();
  1983. if(this.html.active) {
  1984. this._html_play(time);
  1985. } else if(this.aurora.active) {
  1986. this._aurora_play(time);
  1987. } else if(this.flash.active) {
  1988. this._flash_play(time);
  1989. }
  1990. } else {
  1991. this._urlNotSetError("play");
  1992. }
  1993. }
  1994. },
  1995. videoPlay: function() { // Handles clicks on the play button over the video poster
  1996. this.play();
  1997. },
  1998. pause: function(time) {
  1999. time = (typeof time === "number") ? time : NaN; // Remove jQuery event from click handler
  2000. if(this.status.srcSet) {
  2001. if(this.html.active) {
  2002. this._html_pause(time);
  2003. } else if(this.aurora.active) {
  2004. this._aurora_pause(time);
  2005. } else if(this.flash.active) {
  2006. this._flash_pause(time);
  2007. }
  2008. } else {
  2009. this._urlNotSetError("pause");
  2010. }
  2011. },
  2012. tellOthers: function(command, conditions) {
  2013. var self = this,
  2014. hasConditions = typeof conditions === 'function',
  2015. args = Array.prototype.slice.call(arguments); // Convert arguments to an Array.
  2016. if(typeof command !== 'string') { // Ignore, since no command.
  2017. return; // Return undefined to maintain chaining.
  2018. }
  2019. if(hasConditions) {
  2020. args.splice(1, 1); // Remove the conditions from the arguments
  2021. }
  2022. $.jPlayer.prototype.destroyRemoved();
  2023. $.each(this.instances, function() {
  2024. // Remember that "this" is the instance's "element" in the $.each() loop.
  2025. if(self.element !== this) { // Do not tell my instance.
  2026. if(!hasConditions || conditions.call(this.data("jPlayer"), self)) {
  2027. this.jPlayer.apply(this, args);
  2028. }
  2029. }
  2030. });
  2031. },
  2032. pauseOthers: function(time) {
  2033. this.tellOthers("pause", function() {
  2034. // In the conditions function, the "this" context is the other instance's jPlayer object.
  2035. return this.status.srcSet;
  2036. }, time);
  2037. },
  2038. stop: function() {
  2039. if(this.status.srcSet) {
  2040. if(this.html.active) {
  2041. this._html_pause(0);
  2042. } else if(this.aurora.active) {
  2043. this._aurora_pause(0);
  2044. } else if(this.flash.active) {
  2045. this._flash_pause(0);
  2046. }
  2047. } else {
  2048. this._urlNotSetError("stop");
  2049. }
  2050. },
  2051. playHead: function(p) {
  2052. p = this._limitValue(p, 0, 100);
  2053. if(this.status.srcSet) {
  2054. if(this.html.active) {
  2055. this._html_playHead(p);
  2056. } else if(this.aurora.active) {
  2057. this._aurora_playHead(p);
  2058. } else if(this.flash.active) {
  2059. this._flash_playHead(p);
  2060. }
  2061. } else {
  2062. this._urlNotSetError("playHead");
  2063. }
  2064. },
  2065. _muted: function(muted) {
  2066. this.mutedWorker(muted);
  2067. if(this.options.globalVolume) {
  2068. this.tellOthers("mutedWorker", function() {
  2069. // Check the other instance has global volume enabled.
  2070. return this.options.globalVolume;
  2071. }, muted);
  2072. }
  2073. },
  2074. mutedWorker: function(muted) {
  2075. this.options.muted = muted;
  2076. if(this.html.used) {
  2077. this._html_setProperty('muted', muted);
  2078. }
  2079. if(this.aurora.used) {
  2080. this._aurora_mute(muted);
  2081. }
  2082. if(this.flash.used) {
  2083. this._flash_mute(muted);
  2084. }
  2085. // The HTML solution generates this event from the media element itself.
  2086. if(!this.html.video.gate && !this.html.audio.gate) {
  2087. this._updateMute(muted);
  2088. this._updateVolume(this.options.volume);
  2089. this._trigger($.jPlayer.event.volumechange);
  2090. }
  2091. },
  2092. mute: function(mute) { // mute is either: undefined (true), an event object (true) or a boolean (muted).
  2093. var guiAction = typeof mute === "object"; // Flags GUI click events so we know this was not a direct command, but an action taken by the user on the GUI.
  2094. if(guiAction && this.options.useStateClassSkin && this.options.muted) {
  2095. this._muted(false);
  2096. } else {
  2097. mute = mute === undefined ? true : !!mute;
  2098. this._muted(mute);
  2099. }
  2100. },
  2101. unmute: function(unmute) { // unmute is either: undefined (true), an event object (true) or a boolean (!muted).
  2102. unmute = unmute === undefined ? true : !!unmute;
  2103. this._muted(!unmute);
  2104. },
  2105. _updateMute: function(mute) {
  2106. if(mute === undefined) {
  2107. mute = this.options.muted;
  2108. }
  2109. if(mute) {
  2110. this.addStateClass('muted');
  2111. } else {
  2112. this.removeStateClass('muted');
  2113. }
  2114. if(this.css.jq.mute.length && this.css.jq.unmute.length) {
  2115. if(this.status.noVolume) {
  2116. this.css.jq.mute.hide();
  2117. this.css.jq.unmute.hide();
  2118. } else if(mute) {
  2119. this.css.jq.mute.hide();
  2120. this.css.jq.unmute.show();
  2121. } else {
  2122. this.css.jq.mute.show();
  2123. this.css.jq.unmute.hide();
  2124. }
  2125. }
  2126. },
  2127. volume: function(v) {
  2128. this.volumeWorker(v);
  2129. if(this.options.globalVolume) {
  2130. this.tellOthers("volumeWorker", function() {
  2131. // Check the other instance has global volume enabled.
  2132. return this.options.globalVolume;
  2133. }, v);
  2134. }
  2135. },
  2136. volumeWorker: function(v) {
  2137. v = this._limitValue(v, 0, 1);
  2138. this.options.volume = v;
  2139. if(this.html.used) {
  2140. this._html_setProperty('volume', v);
  2141. }
  2142. if(this.aurora.used) {
  2143. this._aurora_volume(v);
  2144. }
  2145. if(this.flash.used) {
  2146. this._flash_volume(v);
  2147. }
  2148. // The HTML solution generates this event from the media element itself.
  2149. if(!this.html.video.gate && !this.html.audio.gate) {
  2150. this._updateVolume(v);
  2151. this._trigger($.jPlayer.event.volumechange);
  2152. }
  2153. },
  2154. volumeBar: function(e) { // Handles clicks on the volumeBar
  2155. if(this.css.jq.volumeBar.length) {
  2156. // Using $(e.currentTarget) to enable multiple volume bars
  2157. var $bar = $(e.currentTarget),
  2158. offset = $bar.offset(),
  2159. x = e.pageX - offset.left,
  2160. w = $bar.width(),
  2161. y = $bar.height() - e.pageY + offset.top,
  2162. h = $bar.height();
  2163. if(this.options.verticalVolume) {
  2164. this.volume(y/h);
  2165. } else {
  2166. this.volume(x/w);
  2167. }
  2168. }
  2169. if(this.options.muted) {
  2170. this._muted(false);
  2171. }
  2172. },
  2173. _updateVolume: function(v) {
  2174. if(v === undefined) {
  2175. v = this.options.volume;
  2176. }
  2177. v = this.options.muted ? 0 : v;
  2178. if(this.status.noVolume) {
  2179. this.addStateClass('noVolume');
  2180. if(this.css.jq.volumeBar.length) {
  2181. this.css.jq.volumeBar.hide();
  2182. }
  2183. if(this.css.jq.volumeBarValue.length) {
  2184. this.css.jq.volumeBarValue.hide();
  2185. }
  2186. if(this.css.jq.volumeMax.length) {
  2187. this.css.jq.volumeMax.hide();
  2188. }
  2189. } else {
  2190. this.removeStateClass('noVolume');
  2191. if(this.css.jq.volumeBar.length) {
  2192. this.css.jq.volumeBar.show();
  2193. }
  2194. if(this.css.jq.volumeBarValue.length) {
  2195. this.css.jq.volumeBarValue.show();
  2196. this.css.jq.volumeBarValue[this.options.verticalVolume ? "height" : "width"]((v*100)+"%");
  2197. }
  2198. if(this.css.jq.volumeMax.length) {
  2199. this.css.jq.volumeMax.show();
  2200. }
  2201. }
  2202. },
  2203. volumeMax: function() { // Handles clicks on the volume max
  2204. this.volume(1);
  2205. if(this.options.muted) {
  2206. this._muted(false);
  2207. }
  2208. },
  2209. _cssSelectorAncestor: function(ancestor) {
  2210. var self = this;
  2211. this.options.cssSelectorAncestor = ancestor;
  2212. this._removeUiClass();
  2213. this.ancestorJq = ancestor ? $(ancestor) : []; // Would use $() instead of [], but it is only 1.4+
  2214. if(ancestor && this.ancestorJq.length !== 1) { // So empty strings do not generate the warning.
  2215. this._warning( {
  2216. type: $.jPlayer.warning.CSS_SELECTOR_COUNT,
  2217. context: ancestor,
  2218. message: $.jPlayer.warningMsg.CSS_SELECTOR_COUNT + this.ancestorJq.length + " found for cssSelectorAncestor.",
  2219. hint: $.jPlayer.warningHint.CSS_SELECTOR_COUNT
  2220. });
  2221. }
  2222. this._addUiClass();
  2223. $.each(this.options.cssSelector, function(fn, cssSel) {
  2224. self._cssSelector(fn, cssSel);
  2225. });
  2226. // Set the GUI to the current state.
  2227. this._updateInterface();
  2228. this._updateButtons();
  2229. this._updateAutohide();
  2230. this._updateVolume();
  2231. this._updateMute();
  2232. },
  2233. _cssSelector: function(fn, cssSel) {
  2234. var self = this;
  2235. if(typeof cssSel === 'string') {
  2236. if($.jPlayer.prototype.options.cssSelector[fn]) {
  2237. if(this.css.jq[fn] && this.css.jq[fn].length) {
  2238. this.css.jq[fn].unbind(".jPlayer");
  2239. }
  2240. this.options.cssSelector[fn] = cssSel;
  2241. this.css.cs[fn] = this.options.cssSelectorAncestor + " " + cssSel;
  2242. if(cssSel) { // Checks for empty string
  2243. this.css.jq[fn] = $(this.css.cs[fn]);
  2244. } else {
  2245. 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.
  2246. }
  2247. if(this.css.jq[fn].length && this[fn]) {
  2248. var handler = function(e) {
  2249. e.preventDefault();
  2250. self[fn](e);
  2251. if(self.options.autoBlur) {
  2252. $(this).blur();
  2253. } else {
  2254. $(this).focus(); // Force focus for ARIA.
  2255. }
  2256. };
  2257. this.css.jq[fn].bind("click.jPlayer", handler); // Using jPlayer namespace
  2258. }
  2259. if(cssSel && this.css.jq[fn].length !== 1) { // So empty strings do not generate the warning. ie., they just remove the old one.
  2260. this._warning( {
  2261. type: $.jPlayer.warning.CSS_SELECTOR_COUNT,
  2262. context: this.css.cs[fn],
  2263. message: $.jPlayer.warningMsg.CSS_SELECTOR_COUNT + this.css.jq[fn].length + " found for " + fn + " method.",
  2264. hint: $.jPlayer.warningHint.CSS_SELECTOR_COUNT
  2265. });
  2266. }
  2267. } else {
  2268. this._warning( {
  2269. type: $.jPlayer.warning.CSS_SELECTOR_METHOD,
  2270. context: fn,
  2271. message: $.jPlayer.warningMsg.CSS_SELECTOR_METHOD,
  2272. hint: $.jPlayer.warningHint.CSS_SELECTOR_METHOD
  2273. });
  2274. }
  2275. } else {
  2276. this._warning( {
  2277. type: $.jPlayer.warning.CSS_SELECTOR_STRING,
  2278. context: cssSel,
  2279. message: $.jPlayer.warningMsg.CSS_SELECTOR_STRING,
  2280. hint: $.jPlayer.warningHint.CSS_SELECTOR_STRING
  2281. });
  2282. }
  2283. },
  2284. duration: function(e) {
  2285. if(this.options.toggleDuration) {
  2286. if(this.options.captureDuration) {
  2287. e.stopPropagation();
  2288. }
  2289. this._setOption("remainingDuration", !this.options.remainingDuration);
  2290. }
  2291. },
  2292. seekBar: function(e) { // Handles clicks on the seekBar
  2293. if(this.css.jq.seekBar.length) {
  2294. // Using $(e.currentTarget) to enable multiple seek bars
  2295. var $bar = $(e.currentTarget),
  2296. offset = $bar.offset(),
  2297. x = e.pageX - offset.left,
  2298. w = $bar.width(),
  2299. p = 100 * x / w;
  2300. this.playHead(p);
  2301. }
  2302. },
  2303. playbackRate: function(pbr) {
  2304. this._setOption("playbackRate", pbr);
  2305. },
  2306. playbackRateBar: function(e) { // Handles clicks on the playbackRateBar
  2307. if(this.css.jq.playbackRateBar.length) {
  2308. // Using $(e.currentTarget) to enable multiple playbackRate bars
  2309. var $bar = $(e.currentTarget),
  2310. offset = $bar.offset(),
  2311. x = e.pageX - offset.left,
  2312. w = $bar.width(),
  2313. y = $bar.height() - e.pageY + offset.top,
  2314. h = $bar.height(),
  2315. ratio, pbr;
  2316. if(this.options.verticalPlaybackRate) {
  2317. ratio = y/h;
  2318. } else {
  2319. ratio = x/w;
  2320. }
  2321. pbr = ratio * (this.options.maxPlaybackRate - this.options.minPlaybackRate) + this.options.minPlaybackRate;
  2322. this.playbackRate(pbr);
  2323. }
  2324. },
  2325. _updatePlaybackRate: function() {
  2326. var pbr = this.options.playbackRate,
  2327. ratio = (pbr - this.options.minPlaybackRate) / (this.options.maxPlaybackRate - this.options.minPlaybackRate);
  2328. if(this.status.playbackRateEnabled) {
  2329. if(this.css.jq.playbackRateBar.length) {
  2330. this.css.jq.playbackRateBar.show();
  2331. }
  2332. if(this.css.jq.playbackRateBarValue.length) {
  2333. this.css.jq.playbackRateBarValue.show();
  2334. this.css.jq.playbackRateBarValue[this.options.verticalPlaybackRate ? "height" : "width"]((ratio*100)+"%");
  2335. }
  2336. } else {
  2337. if(this.css.jq.playbackRateBar.length) {
  2338. this.css.jq.playbackRateBar.hide();
  2339. }
  2340. if(this.css.jq.playbackRateBarValue.length) {
  2341. this.css.jq.playbackRateBarValue.hide();
  2342. }
  2343. }
  2344. },
  2345. repeat: function(event) { // Handle clicks on the repeat button
  2346. var guiAction = typeof event === "object"; // Flags GUI click events so we know this was not a direct command, but an action taken by the user on the GUI.
  2347. if(guiAction && this.options.useStateClassSkin && this.options.loop) {
  2348. this._loop(false);
  2349. } else {
  2350. this._loop(true);
  2351. }
  2352. },
  2353. repeatOff: function() { // Handle clicks on the repeatOff button
  2354. this._loop(false);
  2355. },
  2356. _loop: function(loop) {
  2357. if(this.options.loop !== loop) {
  2358. this.options.loop = loop;
  2359. this._updateButtons();
  2360. this._trigger($.jPlayer.event.repeat);
  2361. }
  2362. },
  2363. // 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.
  2364. option: function(key, value) {
  2365. var options = key;
  2366. // Enables use: options(). Returns a copy of options object
  2367. if ( arguments.length === 0 ) {
  2368. return $.extend( true, {}, this.options );
  2369. }
  2370. if(typeof key === "string") {
  2371. var keys = key.split(".");
  2372. // Enables use: options("someOption") Returns a copy of the option. Supports dot notation.
  2373. if(value === undefined) {
  2374. var opt = $.extend(true, {}, this.options);
  2375. for(var i = 0; i < keys.length; i++) {
  2376. if(opt[keys[i]] !== undefined) {
  2377. opt = opt[keys[i]];
  2378. } else {
  2379. this._warning( {
  2380. type: $.jPlayer.warning.OPTION_KEY,
  2381. context: key,
  2382. message: $.jPlayer.warningMsg.OPTION_KEY,
  2383. hint: $.jPlayer.warningHint.OPTION_KEY
  2384. });
  2385. return undefined;
  2386. }
  2387. }
  2388. return opt;
  2389. }
  2390. // Enables use: options("someOptionObject", someObject}). Creates: {someOptionObject:someObject}
  2391. // Enables use: options("someOption", someValue). Creates: {someOption:someValue}
  2392. // Enables use: options("someOptionObject.someOption", someValue). Creates: {someOptionObject:{someOption:someValue}}
  2393. options = {};
  2394. var opts = options;
  2395. for(var j = 0; j < keys.length; j++) {
  2396. if(j < keys.length - 1) {
  2397. opts[keys[j]] = {};
  2398. opts = opts[keys[j]];
  2399. } else {
  2400. opts[keys[j]] = value;
  2401. }
  2402. }
  2403. }
  2404. // Otherwise enables use: options(optionObject). Uses original object (the key)
  2405. this._setOptions(options);
  2406. return this;
  2407. },
  2408. _setOptions: function(options) {
  2409. var self = this;
  2410. $.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.
  2411. self._setOption(key, value);
  2412. });
  2413. return this;
  2414. },
  2415. _setOption: function(key, value) {
  2416. var self = this;
  2417. // The ability to set options is limited at this time.
  2418. switch(key) {
  2419. case "volume" :
  2420. this.volume(value);
  2421. break;
  2422. case "muted" :
  2423. this._muted(value);
  2424. break;
  2425. case "globalVolume" :
  2426. this.options[key] = value;
  2427. break;
  2428. case "cssSelectorAncestor" :
  2429. this._cssSelectorAncestor(value); // Set and refresh all associations for the new ancestor.
  2430. break;
  2431. case "cssSelector" :
  2432. $.each(value, function(fn, cssSel) {
  2433. self._cssSelector(fn, cssSel); // NB: The option is set inside this function, after further validity checks.
  2434. });
  2435. break;
  2436. case "playbackRate" :
  2437. this.options[key] = value = this._limitValue(value, this.options.minPlaybackRate, this.options.maxPlaybackRate);
  2438. if(this.html.used) {
  2439. this._html_setProperty('playbackRate', value);
  2440. }
  2441. this._updatePlaybackRate();
  2442. break;
  2443. case "defaultPlaybackRate" :
  2444. this.options[key] = value = this._limitValue(value, this.options.minPlaybackRate, this.options.maxPlaybackRate);
  2445. if(this.html.used) {
  2446. this._html_setProperty('defaultPlaybackRate', value);
  2447. }
  2448. this._updatePlaybackRate();
  2449. break;
  2450. case "minPlaybackRate" :
  2451. this.options[key] = value = this._limitValue(value, 0.1, this.options.maxPlaybackRate - 0.1);
  2452. this._updatePlaybackRate();
  2453. break;
  2454. case "maxPlaybackRate" :
  2455. this.options[key] = value = this._limitValue(value, this.options.minPlaybackRate + 0.1, 16);
  2456. this._updatePlaybackRate();
  2457. break;
  2458. case "fullScreen" :
  2459. if(this.options[key] !== value) { // if changed
  2460. var wkv = $.jPlayer.nativeFeatures.fullscreen.used.webkitVideo;
  2461. if(!wkv || wkv && !this.status.waitForPlay) {
  2462. if(!wkv) { // No sensible way to unset option on these devices.
  2463. this.options[key] = value;
  2464. }
  2465. if(value) {
  2466. this._requestFullscreen();
  2467. } else {
  2468. this._exitFullscreen();
  2469. }
  2470. if(!wkv) {
  2471. this._setOption("fullWindow", value);
  2472. }
  2473. }
  2474. }
  2475. break;
  2476. case "fullWindow" :
  2477. if(this.options[key] !== value) { // if changed
  2478. this._removeUiClass();
  2479. this.options[key] = value;
  2480. this._refreshSize();
  2481. }
  2482. break;
  2483. case "size" :
  2484. if(!this.options.fullWindow && this.options[key].cssClass !== value.cssClass) {
  2485. this._removeUiClass();
  2486. }
  2487. this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
  2488. this._refreshSize();
  2489. break;
  2490. case "sizeFull" :
  2491. if(this.options.fullWindow && this.options[key].cssClass !== value.cssClass) {
  2492. this._removeUiClass();
  2493. }
  2494. this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
  2495. this._refreshSize();
  2496. break;
  2497. case "autohide" :
  2498. this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
  2499. this._updateAutohide();
  2500. break;
  2501. case "loop" :
  2502. this._loop(value);
  2503. break;
  2504. case "remainingDuration" :
  2505. this.options[key] = value;
  2506. this._updateInterface();
  2507. break;
  2508. case "toggleDuration" :
  2509. this.options[key] = value;
  2510. break;
  2511. case "nativeVideoControls" :
  2512. this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
  2513. this.status.nativeVideoControls = this._uaBlocklist(this.options.nativeVideoControls);
  2514. this._restrictNativeVideoControls();
  2515. this._updateNativeVideoControls();
  2516. break;
  2517. case "noFullWindow" :
  2518. this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
  2519. this.status.nativeVideoControls = this._uaBlocklist(this.options.nativeVideoControls); // Need to check again as noFullWindow can depend on this flag and the restrict() can override it.
  2520. this.status.noFullWindow = this._uaBlocklist(this.options.noFullWindow);
  2521. this._restrictNativeVideoControls();
  2522. this._updateButtons();
  2523. break;
  2524. case "noVolume" :
  2525. this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
  2526. this.status.noVolume = this._uaBlocklist(this.options.noVolume);
  2527. this._updateVolume();
  2528. this._updateMute();
  2529. break;
  2530. case "emulateHtml" :
  2531. if(this.options[key] !== value) { // To avoid multiple event handlers being created, if true already.
  2532. this.options[key] = value;
  2533. if(value) {
  2534. this._emulateHtmlBridge();
  2535. } else {
  2536. this._destroyHtmlBridge();
  2537. }
  2538. }
  2539. break;
  2540. case "timeFormat" :
  2541. this.options[key] = $.extend({}, this.options[key], value); // store a merged copy of it, incase not all properties changed.
  2542. break;
  2543. case "keyEnabled" :
  2544. this.options[key] = value;
  2545. if(!value && this === $.jPlayer.focus) {
  2546. $.jPlayer.focus = null;
  2547. }
  2548. break;
  2549. case "keyBindings" :
  2550. this.options[key] = $.extend(true, {}, this.options[key], value); // store a merged DEEP copy of it, incase not all properties changed.
  2551. break;
  2552. case "audioFullScreen" :
  2553. this.options[key] = value;
  2554. break;
  2555. case "autoBlur" :
  2556. this.options[key] = value;
  2557. break;
  2558. }
  2559. return this;
  2560. },
  2561. // End of: (Options code adapted from ui.widget.js)
  2562. _refreshSize: function() {
  2563. this._setSize(); // update status and jPlayer element size
  2564. this._addUiClass(); // update the ui class
  2565. this._updateSize(); // update internal sizes
  2566. this._updateButtons();
  2567. this._updateAutohide();
  2568. this._trigger($.jPlayer.event.resize);
  2569. },
  2570. _setSize: function() {
  2571. // Determine the current size from the options
  2572. if(this.options.fullWindow) {
  2573. this.status.width = this.options.sizeFull.width;
  2574. this.status.height = this.options.sizeFull.height;
  2575. this.status.cssClass = this.options.sizeFull.cssClass;
  2576. } else {
  2577. this.status.width = this.options.size.width;
  2578. this.status.height = this.options.size.height;
  2579. this.status.cssClass = this.options.size.cssClass;
  2580. }
  2581. // Set the size of the jPlayer area.
  2582. this.element.css({'width': this.status.width, 'height': this.status.height});
  2583. },
  2584. _addUiClass: function() {
  2585. if(this.ancestorJq.length) {
  2586. this.ancestorJq.addClass(this.status.cssClass);
  2587. }
  2588. },
  2589. _removeUiClass: function() {
  2590. if(this.ancestorJq.length) {
  2591. this.ancestorJq.removeClass(this.status.cssClass);
  2592. }
  2593. },
  2594. _updateSize: function() {
  2595. // The poster uses show/hide so can simply resize it.
  2596. this.internal.poster.jq.css({'width': this.status.width, 'height': this.status.height});
  2597. // Video html or flash resized if necessary at this time, or if native video controls being used.
  2598. if(!this.status.waitForPlay && this.html.active && this.status.video || this.html.video.available && this.html.used && this.status.nativeVideoControls) {
  2599. this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height});
  2600. }
  2601. else if(!this.status.waitForPlay && this.flash.active && this.status.video) {
  2602. this.internal.flash.jq.css({'width': this.status.width, 'height': this.status.height});
  2603. }
  2604. },
  2605. _updateAutohide: function() {
  2606. var self = this,
  2607. event = "mousemove.jPlayer",
  2608. namespace = ".jPlayerAutohide",
  2609. eventType = event + namespace,
  2610. handler = function(event) {
  2611. var moved = false,
  2612. deltaX, deltaY;
  2613. if(typeof self.internal.mouse !== "undefined") {
  2614. //get the change from last position to this position
  2615. deltaX = self.internal.mouse.x - event.pageX;
  2616. deltaY = self.internal.mouse.y - event.pageY;
  2617. moved = (Math.floor(deltaX) > 0) || (Math.floor(deltaY)>0);
  2618. } else {
  2619. moved = true;
  2620. }
  2621. // store current position for next method execution
  2622. self.internal.mouse = {
  2623. x : event.pageX,
  2624. y : event.pageY
  2625. };
  2626. // if mouse has been actually moved, do the gui fadeIn/fadeOut
  2627. if (moved) {
  2628. self.css.jq.gui.fadeIn(self.options.autohide.fadeIn, function() {
  2629. clearTimeout(self.internal.autohideId);
  2630. self.internal.autohideId = setTimeout( function() {
  2631. self.css.jq.gui.fadeOut(self.options.autohide.fadeOut);
  2632. }, self.options.autohide.hold);
  2633. });
  2634. }
  2635. };
  2636. if(this.css.jq.gui.length) {
  2637. // End animations first so that its callback is executed now.
  2638. // Otherwise an in progress fadeIn animation still has the callback to fadeOut again.
  2639. this.css.jq.gui.stop(true, true);
  2640. // Removes the fadeOut operation from the fadeIn callback.
  2641. clearTimeout(this.internal.autohideId);
  2642. // undefine mouse
  2643. delete this.internal.mouse;
  2644. this.element.unbind(namespace);
  2645. this.css.jq.gui.unbind(namespace);
  2646. if(!this.status.nativeVideoControls) {
  2647. if(this.options.fullWindow && this.options.autohide.full || !this.options.fullWindow && this.options.autohide.restored) {
  2648. this.element.bind(eventType, handler);
  2649. this.css.jq.gui.bind(eventType, handler);
  2650. this.css.jq.gui.hide();
  2651. } else {
  2652. this.css.jq.gui.show();
  2653. }
  2654. } else {
  2655. this.css.jq.gui.hide();
  2656. }
  2657. }
  2658. },
  2659. fullScreen: function(event) {
  2660. var guiAction = typeof event === "object"; // Flags GUI click events so we know this was not a direct command, but an action taken by the user on the GUI.
  2661. if(guiAction && this.options.useStateClassSkin && this.options.fullScreen) {
  2662. this._setOption("fullScreen", false);
  2663. } else {
  2664. this._setOption("fullScreen", true);
  2665. }
  2666. },
  2667. restoreScreen: function() {
  2668. this._setOption("fullScreen", false);
  2669. },
  2670. _fullscreenAddEventListeners: function() {
  2671. var self = this,
  2672. fs = $.jPlayer.nativeFeatures.fullscreen;
  2673. if(fs.api.fullscreenEnabled) {
  2674. if(fs.event.fullscreenchange) {
  2675. // Create the event handler function and store it for removal.
  2676. if(typeof this.internal.fullscreenchangeHandler !== 'function') {
  2677. this.internal.fullscreenchangeHandler = function() {
  2678. self._fullscreenchange();
  2679. };
  2680. }
  2681. document.addEventListener(fs.event.fullscreenchange, this.internal.fullscreenchangeHandler, false);
  2682. }
  2683. // No point creating handler for fullscreenerror.
  2684. // Either logic avoids fullscreen occurring (w3c/moz), or their is no event on the browser (webkit).
  2685. }
  2686. },
  2687. _fullscreenRemoveEventListeners: function() {
  2688. var fs = $.jPlayer.nativeFeatures.fullscreen;
  2689. if(this.internal.fullscreenchangeHandler) {
  2690. document.removeEventListener(fs.event.fullscreenchange, this.internal.fullscreenchangeHandler, false);
  2691. }
  2692. },
  2693. _fullscreenchange: function() {
  2694. // If nothing is fullscreen, then we cannot be in fullscreen mode.
  2695. if(this.options.fullScreen && !$.jPlayer.nativeFeatures.fullscreen.api.fullscreenElement()) {
  2696. this._setOption("fullScreen", false);
  2697. }
  2698. },
  2699. _requestFullscreen: function() {
  2700. // Either the container or the jPlayer div
  2701. var e = this.ancestorJq.length ? this.ancestorJq[0] : this.element[0],
  2702. fs = $.jPlayer.nativeFeatures.fullscreen;
  2703. // This method needs the video element. For iOS and Android.
  2704. if(fs.used.webkitVideo) {
  2705. e = this.htmlElement.video;
  2706. }
  2707. if(fs.api.fullscreenEnabled) {
  2708. fs.api.requestFullscreen(e);
  2709. }
  2710. },
  2711. _exitFullscreen: function() {
  2712. var fs = $.jPlayer.nativeFeatures.fullscreen,
  2713. e;
  2714. // This method needs the video element. For iOS and Android.
  2715. if(fs.used.webkitVideo) {
  2716. e = this.htmlElement.video;
  2717. }
  2718. if(fs.api.fullscreenEnabled) {
  2719. fs.api.exitFullscreen(e);
  2720. }
  2721. },
  2722. _html_initMedia: function(media) {
  2723. // Remove any existing track elements
  2724. var $media = $(this.htmlElement.media).empty();
  2725. // Create any track elements given with the media, as an Array of track Objects.
  2726. $.each(media.track || [], function(i,v) {
  2727. var track = document.createElement('track');
  2728. track.setAttribute("kind", v.kind ? v.kind : "");
  2729. track.setAttribute("src", v.src ? v.src : "");
  2730. track.setAttribute("srclang", v.srclang ? v.srclang : "");
  2731. track.setAttribute("label", v.label ? v.label : "");
  2732. if(v.def) {
  2733. track.setAttribute("default", v.def);
  2734. }
  2735. $media.append(track);
  2736. });
  2737. this.htmlElement.media.src = this.status.src;
  2738. if(this.options.preload !== 'none') {
  2739. this._html_load(); // See function for comments
  2740. }
  2741. this._trigger($.jPlayer.event.timeupdate); // The flash generates this event for its solution.
  2742. },
  2743. _html_setFormat: function(media) {
  2744. var self = this;
  2745. // Always finds a format due to checks in setMedia()
  2746. $.each(this.formats, function(priority, format) {
  2747. if(self.html.support[format] && media[format]) {
  2748. self.status.src = media[format];
  2749. self.status.format[format] = true;
  2750. self.status.formatType = format;
  2751. return false;
  2752. }
  2753. });
  2754. },
  2755. _html_setAudio: function(media) {
  2756. this._html_setFormat(media);
  2757. this.htmlElement.media = this.htmlElement.audio;
  2758. this._html_initMedia(media);
  2759. },
  2760. _html_setVideo: function(media) {
  2761. this._html_setFormat(media);
  2762. if(this.status.nativeVideoControls) {
  2763. this.htmlElement.video.poster = this._validString(media.poster) ? media.poster : "";
  2764. }
  2765. this.htmlElement.media = this.htmlElement.video;
  2766. this._html_initMedia(media);
  2767. },
  2768. _html_resetMedia: function() {
  2769. if(this.htmlElement.media) {
  2770. if(this.htmlElement.media.id === this.internal.video.id && !this.status.nativeVideoControls) {
  2771. this.internal.video.jq.css({'width':'0px', 'height':'0px'});
  2772. }
  2773. this.htmlElement.media.pause();
  2774. }
  2775. },
  2776. _html_clearMedia: function() {
  2777. if(this.htmlElement.media) {
  2778. this.htmlElement.media.src = "about:blank";
  2779. // The following load() is only required for Firefox 3.6 (PowerMacs).
  2780. // Recent HTMl5 browsers only require the src change. Due to changes in W3C spec and load() effect.
  2781. 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.
  2782. }
  2783. },
  2784. _html_load: function() {
  2785. // This function remains to allow the early HTML5 browsers to work, such as Firefox 3.6
  2786. // A change in the W3C spec for the media.load() command means that this is no longer necessary.
  2787. // 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.
  2788. if(this.status.waitForLoad) {
  2789. this.status.waitForLoad = false;
  2790. this.htmlElement.media.load();
  2791. }
  2792. clearTimeout(this.internal.htmlDlyCmdId);
  2793. },
  2794. _html_play: function(time) {
  2795. var self = this,
  2796. media = this.htmlElement.media;
  2797. this.androidFix.pause = false; // Cancel the pause fix.
  2798. this._html_load(); // Loads if required and clears any delayed commands.
  2799. // Setup the Android Fix.
  2800. if(this.androidFix.setMedia) {
  2801. this.androidFix.play = true;
  2802. this.androidFix.time = time;
  2803. } else if(!isNaN(time)) {
  2804. // Attempt to play it, since iOS has been ignoring commands
  2805. if(this.internal.cmdsIgnored) {
  2806. media.play();
  2807. }
  2808. try {
  2809. // !media.seekable is for old HTML5 browsers, like Firefox 3.6.
  2810. // Checking seekable.length is important for iOS6 to work with setMedia().play(time)
  2811. if(!media.seekable || typeof media.seekable === "object" && media.seekable.length > 0) {
  2812. media.currentTime = time;
  2813. media.play();
  2814. } else {
  2815. throw 1;
  2816. }
  2817. } catch(err) {
  2818. this.internal.htmlDlyCmdId = setTimeout(function() {
  2819. self.play(time);
  2820. }, 250);
  2821. return; // Cancel execution and wait for the delayed command.
  2822. }
  2823. } else {
  2824. media.play();
  2825. }
  2826. this._html_checkWaitForPlay();
  2827. },
  2828. _html_pause: function(time) {
  2829. var self = this,
  2830. media = this.htmlElement.media;
  2831. this.androidFix.play = false; // Cancel the play fix.
  2832. if(time > 0) { // We do not want the stop() command, which does pause(0), causing a load operation.
  2833. this._html_load(); // Loads if required and clears any delayed commands.
  2834. } else {
  2835. clearTimeout(this.internal.htmlDlyCmdId);
  2836. }
  2837. // Order of these commands is important for Safari (Win) and IE9. Pause then change currentTime.
  2838. media.pause();
  2839. // Setup the Android Fix.
  2840. if(this.androidFix.setMedia) {
  2841. this.androidFix.pause = true;
  2842. this.androidFix.time = time;
  2843. } else if(!isNaN(time)) {
  2844. try {
  2845. if(!media.seekable || typeof media.seekable === "object" && media.seekable.length > 0) {
  2846. media.currentTime = time;
  2847. } else {
  2848. throw 1;
  2849. }
  2850. } catch(err) {
  2851. this.internal.htmlDlyCmdId = setTimeout(function() {
  2852. self.pause(time);
  2853. }, 250);
  2854. return; // Cancel execution and wait for the delayed command.
  2855. }
  2856. }
  2857. if(time > 0) { // Avoids a setMedia() followed by stop() or pause(0) hiding the video play button.
  2858. this._html_checkWaitForPlay();
  2859. }
  2860. },
  2861. _html_playHead: function(percent) {
  2862. var self = this,
  2863. media = this.htmlElement.media;
  2864. this._html_load(); // Loads if required and clears any delayed commands.
  2865. // This playHead() method needs a refactor to apply the android fix.
  2866. try {
  2867. if(typeof media.seekable === "object" && media.seekable.length > 0) {
  2868. media.currentTime = percent * media.seekable.end(media.seekable.length-1) / 100;
  2869. } else if(media.duration > 0 && !isNaN(media.duration)) {
  2870. media.currentTime = percent * media.duration / 100;
  2871. } else {
  2872. throw "e";
  2873. }
  2874. } catch(err) {
  2875. this.internal.htmlDlyCmdId = setTimeout(function() {
  2876. self.playHead(percent);
  2877. }, 250);
  2878. return; // Cancel execution and wait for the delayed command.
  2879. }
  2880. if(!this.status.waitForLoad) {
  2881. this._html_checkWaitForPlay();
  2882. }
  2883. },
  2884. _html_checkWaitForPlay: function() {
  2885. if(this.status.waitForPlay) {
  2886. this.status.waitForPlay = false;
  2887. if(this.css.jq.videoPlay.length) {
  2888. this.css.jq.videoPlay.hide();
  2889. }
  2890. if(this.status.video) {
  2891. this.internal.poster.jq.hide();
  2892. this.internal.video.jq.css({'width': this.status.width, 'height': this.status.height});
  2893. }
  2894. }
  2895. },
  2896. _html_setProperty: function(property, value) {
  2897. if(this.html.audio.available) {
  2898. this.htmlElement.audio[property] = value;
  2899. }
  2900. if(this.html.video.available) {
  2901. this.htmlElement.video[property] = value;
  2902. }
  2903. },
  2904. _aurora_setAudio: function(media) {
  2905. var self = this;
  2906. // Always finds a format due to checks in setMedia()
  2907. $.each(this.formats, function(priority, format) {
  2908. if(self.aurora.support[format] && media[format]) {
  2909. self.status.src = media[format];
  2910. self.status.format[format] = true;
  2911. self.status.formatType = format;
  2912. return false;
  2913. }
  2914. });
  2915. this.aurora.player = new AV.Player.fromURL(this.status.src);
  2916. this._addAuroraEventListeners(this.aurora.player, this.aurora);
  2917. if(this.options.preload === 'auto') {
  2918. this._aurora_load();
  2919. this.status.waitForLoad = false;
  2920. }
  2921. },
  2922. _aurora_resetMedia: function() {
  2923. if (this.aurora.player) {
  2924. this.aurora.player.stop();
  2925. }
  2926. },
  2927. _aurora_clearMedia: function() {
  2928. // Nothing to clear.
  2929. },
  2930. _aurora_load: function() {
  2931. if(this.status.waitForLoad) {
  2932. this.status.waitForLoad = false;
  2933. this.aurora.player.preload();
  2934. }
  2935. },
  2936. _aurora_play: function(time) {
  2937. if (!this.status.waitForLoad) {
  2938. if (!isNaN(time)) {
  2939. this.aurora.player.seek(time);
  2940. }
  2941. }
  2942. if (!this.aurora.player.playing) {
  2943. this.aurora.player.play();
  2944. }
  2945. this.status.waitForLoad = false;
  2946. this._aurora_checkWaitForPlay();
  2947. // No event from the player, update UI now.
  2948. this._updateButtons(true);
  2949. this._trigger($.jPlayer.event.play);
  2950. },
  2951. _aurora_pause: function(time) {
  2952. if (!isNaN(time)) {
  2953. this.aurora.player.seek(time * 1000);
  2954. }
  2955. this.aurora.player.pause();
  2956. if(time > 0) { // Avoids a setMedia() followed by stop() or pause(0) hiding the video play button.
  2957. this._aurora_checkWaitForPlay();
  2958. }
  2959. // No event from the player, update UI now.
  2960. this._updateButtons(false);
  2961. this._trigger($.jPlayer.event.pause);
  2962. },
  2963. _aurora_playHead: function(percent) {
  2964. if(this.aurora.player.duration > 0) {
  2965. // The seek() sould be in milliseconds, but the only codec that works with seek (aac.js) uses seconds.
  2966. this.aurora.player.seek(percent * this.aurora.player.duration / 100); // Using seconds
  2967. }
  2968. if(!this.status.waitForLoad) {
  2969. this._aurora_checkWaitForPlay();
  2970. }
  2971. },
  2972. _aurora_checkWaitForPlay: function() {
  2973. if(this.status.waitForPlay) {
  2974. this.status.waitForPlay = false;
  2975. }
  2976. },
  2977. _aurora_volume: function(v) {
  2978. this.aurora.player.volume = v * 100;
  2979. },
  2980. _aurora_mute: function(m) {
  2981. if (m) {
  2982. this.aurora.properties.lastvolume = this.aurora.player.volume;
  2983. this.aurora.player.volume = 0;
  2984. } else {
  2985. this.aurora.player.volume = this.aurora.properties.lastvolume;
  2986. }
  2987. this.aurora.properties.muted = m;
  2988. },
  2989. _flash_setAudio: function(media) {
  2990. var self = this;
  2991. try {
  2992. // Always finds a format due to checks in setMedia()
  2993. $.each(this.formats, function(priority, format) {
  2994. if(self.flash.support[format] && media[format]) {
  2995. switch (format) {
  2996. case "m4a" :
  2997. case "fla" :
  2998. self._getMovie().fl_setAudio_m4a(media[format]);
  2999. break;
  3000. case "mp3" :
  3001. self._getMovie().fl_setAudio_mp3(media[format]);
  3002. break;
  3003. case "rtmpa":
  3004. self._getMovie().fl_setAudio_rtmp(media[format]);
  3005. break;
  3006. }
  3007. self.status.src = media[format];
  3008. self.status.format[format] = true;
  3009. self.status.formatType = format;
  3010. return false;
  3011. }
  3012. });
  3013. if(this.options.preload === 'auto') {
  3014. this._flash_load();
  3015. this.status.waitForLoad = false;
  3016. }
  3017. } catch(err) { this._flashError(err); }
  3018. },
  3019. _flash_setVideo: function(media) {
  3020. var self = this;
  3021. try {
  3022. // Always finds a format due to checks in setMedia()
  3023. $.each(this.formats, function(priority, format) {
  3024. if(self.flash.support[format] && media[format]) {
  3025. switch (format) {
  3026. case "m4v" :
  3027. case "flv" :
  3028. self._getMovie().fl_setVideo_m4v(media[format]);
  3029. break;
  3030. case "rtmpv":
  3031. self._getMovie().fl_setVideo_rtmp(media[format]);
  3032. break;
  3033. }
  3034. self.status.src = media[format];
  3035. self.status.format[format] = true;
  3036. self.status.formatType = format;
  3037. return false;
  3038. }
  3039. });
  3040. if(this.options.preload === 'auto') {
  3041. this._flash_load();
  3042. this.status.waitForLoad = false;
  3043. }
  3044. } catch(err) { this._flashError(err); }
  3045. },
  3046. _flash_resetMedia: function() {
  3047. this.internal.flash.jq.css({'width':'0px', 'height':'0px'}); // Must do via CSS as setting attr() to zero causes a jQuery error in IE.
  3048. this._flash_pause(NaN);
  3049. },
  3050. _flash_clearMedia: function() {
  3051. try {
  3052. this._getMovie().fl_clearMedia();
  3053. } catch(err) { this._flashError(err); }
  3054. },
  3055. _flash_load: function() {
  3056. try {
  3057. this._getMovie().fl_load();
  3058. } catch(err) { this._flashError(err); }
  3059. this.status.waitForLoad = false;
  3060. },
  3061. _flash_play: function(time) {
  3062. try {
  3063. this._getMovie().fl_play(time);
  3064. } catch(err) { this._flashError(err); }
  3065. this.status.waitForLoad = false;
  3066. this._flash_checkWaitForPlay();
  3067. },
  3068. _flash_pause: function(time) {
  3069. try {
  3070. this._getMovie().fl_pause(time);
  3071. } catch(err) { this._flashError(err); }
  3072. if(time > 0) { // Avoids a setMedia() followed by stop() or pause(0) hiding the video play button.
  3073. this.status.waitForLoad = false;
  3074. this._flash_checkWaitForPlay();
  3075. }
  3076. },
  3077. _flash_playHead: function(p) {
  3078. try {
  3079. this._getMovie().fl_play_head(p);
  3080. } catch(err) { this._flashError(err); }
  3081. if(!this.status.waitForLoad) {
  3082. this._flash_checkWaitForPlay();
  3083. }
  3084. },
  3085. _flash_checkWaitForPlay: function() {
  3086. if(this.status.waitForPlay) {
  3087. this.status.waitForPlay = false;
  3088. if(this.css.jq.videoPlay.length) {
  3089. this.css.jq.videoPlay.hide();
  3090. }
  3091. if(this.status.video) {
  3092. this.internal.poster.jq.hide();
  3093. this.internal.flash.jq.css({'width': this.status.width, 'height': this.status.height});
  3094. }
  3095. }
  3096. },
  3097. _flash_volume: function(v) {
  3098. try {
  3099. this._getMovie().fl_volume(v);
  3100. } catch(err) { this._flashError(err); }
  3101. },
  3102. _flash_mute: function(m) {
  3103. try {
  3104. this._getMovie().fl_mute(m);
  3105. } catch(err) { this._flashError(err); }
  3106. },
  3107. _getMovie: function() {
  3108. return document[this.internal.flash.id];
  3109. },
  3110. _getFlashPluginVersion: function() {
  3111. // _getFlashPluginVersion() code influenced by:
  3112. // - FlashReplace 1.01: http://code.google.com/p/flashreplace/
  3113. // - SWFObject 2.2: http://code.google.com/p/swfobject/
  3114. var version = 0,
  3115. flash;
  3116. if(window.ActiveXObject) {
  3117. try {
  3118. flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
  3119. if (flash) { // flash will return null when ActiveX is disabled
  3120. var v = flash.GetVariable("$version");
  3121. if(v) {
  3122. v = v.split(" ")[1].split(",");
  3123. version = parseInt(v[0], 10) + "." + parseInt(v[1], 10);
  3124. }
  3125. }
  3126. } catch(e) {}
  3127. }
  3128. else if(navigator.plugins && navigator.mimeTypes.length > 0) {
  3129. flash = navigator.plugins["Shockwave Flash"];
  3130. if(flash) {
  3131. version = navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/, "$1");
  3132. }
  3133. }
  3134. return version * 1; // Converts to a number
  3135. },
  3136. _checkForFlash: function (version) {
  3137. var flashOk = false;
  3138. if(this._getFlashPluginVersion() >= version) {
  3139. flashOk = true;
  3140. }
  3141. return flashOk;
  3142. },
  3143. _validString: function(url) {
  3144. return (url && typeof url === "string"); // Empty strings return false
  3145. },
  3146. _limitValue: function(value, min, max) {
  3147. return (value < min) ? min : ((value > max) ? max : value);
  3148. },
  3149. _urlNotSetError: function(context) {
  3150. this._error( {
  3151. type: $.jPlayer.error.URL_NOT_SET,
  3152. context: context,
  3153. message: $.jPlayer.errorMsg.URL_NOT_SET,
  3154. hint: $.jPlayer.errorHint.URL_NOT_SET
  3155. });
  3156. },
  3157. _flashError: function(error) {
  3158. var errorType;
  3159. if(!this.internal.ready) {
  3160. errorType = "FLASH";
  3161. } else {
  3162. errorType = "FLASH_DISABLED";
  3163. }
  3164. this._error( {
  3165. type: $.jPlayer.error[errorType],
  3166. context: this.internal.flash.swf,
  3167. message: $.jPlayer.errorMsg[errorType] + error.message,
  3168. hint: $.jPlayer.errorHint[errorType]
  3169. });
  3170. // Allow the audio player to recover if display:none and then shown again, or with position:fixed on Firefox.
  3171. // This really only affects audio in a media player, as an audio player could easily move the jPlayer element away from such issues.
  3172. this.internal.flash.jq.css({'width':'1px', 'height':'1px'});
  3173. },
  3174. _error: function(error) {
  3175. this._trigger($.jPlayer.event.error, error);
  3176. if(this.options.errorAlerts) {
  3177. this._alert("Error!" + (error.message ? "\n" + error.message : "") + (error.hint ? "\n" + error.hint : "") + "\nContext: " + error.context);
  3178. }
  3179. },
  3180. _warning: function(warning) {
  3181. this._trigger($.jPlayer.event.warning, undefined, warning);
  3182. if(this.options.warningAlerts) {
  3183. this._alert("Warning!" + (warning.message ? "\n" + warning.message : "") + (warning.hint ? "\n" + warning.hint : "") + "\nContext: " + warning.context);
  3184. }
  3185. },
  3186. _alert: function(message) {
  3187. var msg = "jPlayer " + this.version.script + " : id='" + this.internal.self.id +"' : " + message;
  3188. if(!this.options.consoleAlerts) {
  3189. alert(msg);
  3190. } else if(window.console && window.console.log) {
  3191. window.console.log(msg);
  3192. }
  3193. },
  3194. _emulateHtmlBridge: function() {
  3195. var self = this;
  3196. // Emulate methods on jPlayer's DOM element.
  3197. $.each( $.jPlayer.emulateMethods.split(/\s+/g), function(i, name) {
  3198. self.internal.domNode[name] = function(arg) {
  3199. self[name](arg);
  3200. };
  3201. });
  3202. // Bubble jPlayer events to its DOM element.
  3203. $.each($.jPlayer.event, function(eventName,eventType) {
  3204. var nativeEvent = true;
  3205. $.each( $.jPlayer.reservedEvent.split(/\s+/g), function(i, name) {
  3206. if(name === eventName) {
  3207. nativeEvent = false;
  3208. return false;
  3209. }
  3210. });
  3211. if(nativeEvent) {
  3212. self.element.bind(eventType + ".jPlayer.jPlayerHtml", function() { // With .jPlayer & .jPlayerHtml namespaces.
  3213. self._emulateHtmlUpdate();
  3214. var domEvent = document.createEvent("Event");
  3215. domEvent.initEvent(eventName, false, true);
  3216. self.internal.domNode.dispatchEvent(domEvent);
  3217. });
  3218. }
  3219. // The error event would require a special case
  3220. });
  3221. // 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.
  3222. },
  3223. _emulateHtmlUpdate: function() {
  3224. var self = this;
  3225. $.each( $.jPlayer.emulateStatus.split(/\s+/g), function(i, name) {
  3226. self.internal.domNode[name] = self.status[name];
  3227. });
  3228. $.each( $.jPlayer.emulateOptions.split(/\s+/g), function(i, name) {
  3229. self.internal.domNode[name] = self.options[name];
  3230. });
  3231. },
  3232. _destroyHtmlBridge: function() {
  3233. var self = this;
  3234. // Bridge event handlers are also removed by destroy() through .jPlayer namespace.
  3235. this.element.unbind(".jPlayerHtml"); // Remove all event handlers created by the jPlayer bridge. So you can change the emulateHtml option.
  3236. // Remove the methods and properties
  3237. var emulated = $.jPlayer.emulateMethods + " " + $.jPlayer.emulateStatus + " " + $.jPlayer.emulateOptions;
  3238. $.each( emulated.split(/\s+/g), function(i, name) {
  3239. delete self.internal.domNode[name];
  3240. });
  3241. }
  3242. };
  3243. $.jPlayer.error = {
  3244. FLASH: "e_flash",
  3245. FLASH_DISABLED: "e_flash_disabled",
  3246. NO_SOLUTION: "e_no_solution",
  3247. NO_SUPPORT: "e_no_support",
  3248. URL: "e_url",
  3249. URL_NOT_SET: "e_url_not_set",
  3250. VERSION: "e_version"
  3251. };
  3252. $.jPlayer.errorMsg = {
  3253. FLASH: "jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ", // Used in: _flashError()
  3254. FLASH_DISABLED: "jPlayer's Flash fallback has been disabled by the browser due to the CSS rules you have used. Details: ", // Used in: _flashError()
  3255. NO_SOLUTION: "No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.", // Used in: _init()
  3256. NO_SUPPORT: "It is not possible to play any media format provided in setMedia() on this browser using your current options.", // Used in: setMedia()
  3257. URL: "Media URL could not be loaded.", // Used in: jPlayerFlashEvent() and _addHtmlEventListeners()
  3258. URL_NOT_SET: "Attempt to issue media playback commands, while no media url is set.", // Used in: load(), play(), pause(), stop() and playHead()
  3259. VERSION: "jPlayer " + $.jPlayer.prototype.version.script + " needs Jplayer.swf version " + $.jPlayer.prototype.version.needFlash + " but found " // Used in: jPlayerReady()
  3260. };
  3261. $.jPlayer.errorHint = {
  3262. FLASH: "Check your swfPath option and that Jplayer.swf is there.",
  3263. FLASH_DISABLED: "Check that you have not display:none; the jPlayer entity or any ancestor.",
  3264. NO_SOLUTION: "Review the jPlayer options: support and supplied.",
  3265. NO_SUPPORT: "Video or audio formats defined in the supplied option are missing.",
  3266. URL: "Check media URL is valid.",
  3267. URL_NOT_SET: "Use setMedia() to set the media URL.",
  3268. VERSION: "Update jPlayer files."
  3269. };
  3270. $.jPlayer.warning = {
  3271. CSS_SELECTOR_COUNT: "e_css_selector_count",
  3272. CSS_SELECTOR_METHOD: "e_css_selector_method",
  3273. CSS_SELECTOR_STRING: "e_css_selector_string",
  3274. OPTION_KEY: "e_option_key"
  3275. };
  3276. $.jPlayer.warningMsg = {
  3277. CSS_SELECTOR_COUNT: "The number of css selectors found did not equal one: ",
  3278. CSS_SELECTOR_METHOD: "The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.",
  3279. CSS_SELECTOR_STRING: "The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.",
  3280. OPTION_KEY: "The option requested in jPlayer('option') is undefined."
  3281. };
  3282. $.jPlayer.warningHint = {
  3283. CSS_SELECTOR_COUNT: "Check your css selector and the ancestor.",
  3284. CSS_SELECTOR_METHOD: "Check your method name.",
  3285. CSS_SELECTOR_STRING: "Check your css selector is a string.",
  3286. OPTION_KEY: "Check your option name."
  3287. };
  3288. }));