- var cssSelector = $(this).data("jPlayerInspector").jPlayer.jPlayer("option", "cssSelector");
- for(prop in cssSelector) {
-
- // jPlayerInfo += "<br /> " + prop + ": '" + cssSelector[prop] + "'," // This works too of course, but want to use option method for deep keys.
- var JQUERY_SCRIPT = '//code.jquery.com/jquery-1.11.1.min.js', // Used if jQuery not already present.
- JPLAYER_SCRIPT = '//www.jplayer.org/2.7.0/js/jquery.jplayer.min.js', // Used if jPlayer not already present.
- JPLAYER_SWFPATH = '//www.jplayer.org/2.7.0/js/Jplayer.swf', // Used if not specified in jPlayer options via SRC Object.
- SOLUTION = 'html,flash', // The default solution option.
- DEBUG = false, // Decided to leave the debugging option and console output in for the time being. Overhead is trivial.
- jQueryDownloading = false, // Flag to stop multiple instances from each pulling in jQuery, thus corrupting it.
- jPlayerDownloading = false, // Flag to stop multiple instances from each pulling in jPlayer, thus corrupting it.
- format = { // Duplicate of jPlayer 2.5.0 object, to avoid always requiring jQuery and jPlayer to be loaded before performing the _canPlayType() test.
- // This may not work properly when both audio and video is supplied. ie., A media player. But it should return truethy and jPlayer can figure it out.
-
- var solution = srcObj.options.solution.toLowerCase().split(","), // Create the solution array, with prority based on the order of the solution string.
- supplied = srcObj.options.supplied.toLowerCase().split(","); // Create the supplied formats array, with prority based on the order of the supplied formats string.
-
- for(var sol = 0; sol < solution.length; sol++) {
-
- var solutionType = solution[sol].replace(/^\s+|\s+$/g, ""), //trim
- myPlayer, // The jQuery selector of the jPlayer element. Usually a <div>
- jPlayerObj, // The jPlayer data instance. For performance and DRY code.
- mediaType = 'unknown',
- jpMedia = {},
- jpOptions = {},
- ready = false, // Used during init to override the annoying duration dependance in the track event padding during Popcorn's isReady(). ie., We is ready after loadeddata and duration can then be set real value at leisure.
- duration = 0, // For the durationchange event with both HTML5 and Flash solutions. Used with 'ready' to keep control during the Popcorn isReady() via loadeddata event. (Duration=0 is bad.)
- durationchangeId = null, // A timeout ID used with delayed durationchange event. (Because of the duration=NaN fudge to avoid Popcorn track event corruption.)
- // Do not auto-bubble the reserved events, nor the loadeddata and durationchange event, since the duration must be carefully handled when loadeddata event occurs.
- // See the duration property code for more details. (Ranting.)
-
- var reservedEvents = $.jPlayer.reservedEvent + ' loadeddata durationchange',
- reservedEvent = reservedEvents.split(/\s+/g);
-
- // Generate event handlers for all the standard HTML5 media events. (Except durationchange)
- if(DEBUG) console.log('Dispatched event: ' + name + (event && event.jPlayer ? ' (' + event.jPlayer.status.currentTime + 's)' : '')); // Must be after dispatch for some reason on Firefox/Opera
- // The error event is a special case. Plus jPlayer error event assumes it is a broken URL. (It could also be a decoder error... Or aborted or a Network error.)
- // Not sure how to handle the error situation. Popcorn does not appear to have the error or error.code property documented here: http://popcornjs.org/popcorn-docs/media-methods/
- // If any error event happens, then something has gone pear shaped.
-
- error = event.jPlayer.error; // Saving object pointer, not a copy of the object. Possible garbage collection issue... But the player is dead anyway, so don't care.
-
- if(error.type === $.jPlayer.error.URL) {
- error.code = 4; // MEDIA_ERR_SRC_NOT_SUPPORTED since jPlayer makes this assumption. It is the most common error, then the decode error. Never seen either of the other 2 error types occur.
- } else {
- error.code = 0; // It was a jPlayer error, not an HTML5 media error.
- * videoDurationPlus = Number.MAX_VALUE; // Who cares if the padding is close to the real duration?
- * So if you trigger loadeddata before the duration is correct, the track event padding is screwed up. (It pads the start, not the end... Well, duration+1 = 0+1 = 1s)
- * That line makes the MP3 Flash fallback difficult to setup. The whole MP3 will need to load before the duration is known.
- * Planning on using a NaN for duration until a >0 value is found... Except with MP3, where seekPercent must be 100% before setting the duration.
- * Why not just use a NaN during init... And then correct the duration later?
- equal( vwf.execute( derivedBaseBehaviorID, "this.derivedBaseBehavior" ), "derivedBaseBehavior", "derived property visible on derived with base behavior" );
- equal( vwf.execute( derivedBaseBehaviorID, "this.baseBehavior" ), "baseBehavior", "base behavior property visible on derived with base behavior" );
- equal( vwf.execute( derivedBaseBehaviorID, "this.base" ), "base", "base property visible on derived with base behavior" );
-
- equal( vwf.execute( derivedBaseBehaviorID, "this.derivedBaseBehaviorAccessor" ), "DERIVEDBASEBEHAVIOR", "derived property visible on derived with base behavior through accessor" );
- equal( vwf.execute( derivedBaseBehaviorID, "this.baseBehaviorAccessor" ), "BASEBEHAVIOR", "base behavior property visible on derived with base behavior through accessor" );
- equal( vwf.execute( derivedBaseBehaviorID, "this.baseAccessor" ), "BASE", "base property visible on derived with base behavior through accessor" );
- equal( vwf.execute( derivedBaseBehaviorID, "this.derivedBaseBehavior" ), "UpDaTeD", "derived property after initialization on derived with base behavior" );
- equal( vwf.execute( derivedBaseBehaviorID, "this.baseBehavior" ), "UpDaTeD", "base behavior property after initialization on derived with base behavior" );
- equal( vwf.execute( derivedBaseBehaviorID, "this.base" ), "UpDaTeD", "base property after initialization on derived with base behavior" );
-
- equal( vwf.execute( derivedBaseBehaviorID, "this.derivedBaseBehaviorAccessor" ), "UPDATED", "derived property after initialization on derived with base behavior through accessor" );
- equal( vwf.execute( derivedBaseBehaviorID, "this.baseBehaviorAccessor" ), "UPDATED", "base behavior property after initialization on derived with base behavior through accessor" );
- equal( vwf.execute( derivedBaseBehaviorID, "this.baseAccessor" ), "UPDATED", "base property after initialization on derived with base behavior through accessor" );
-
- cleanup();
- start();
-
- } );
-
- } );
-
- asyncTest( "Inheritance through two behaviors", function() { // DerivedBaseBehaviorOtherBehavior implements BaseBehavior, OtherBehavior extends Base
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.derivedBaseBehaviorOtherBehavior" ), "derivedBaseBehaviorOtherBehavior", "derived property visible on derived with base and other behaviors" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.baseBehavior" ), "baseBehavior", "base behavior property visible on derived with base and other behaviors" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.otherBehavior" ), "otherBehavior", "other behavior property visible on derived with base and other behaviors" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.base" ), "base", "base property visible on derived with base and other behaviors" );
-
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.derivedBaseBehaviorOtherBehaviorAccessor" ), "DERIVEDBASEBEHAVIOROTHERBEHAVIOR", "derived property visible on derived with base and other behaviors through accessor" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.baseBehaviorAccessor" ), "BASEBEHAVIOR", "base behavior property visible on derived with base and other behaviors through accessor" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.otherBehaviorAccessor" ), "OTHERBEHAVIOR", "other behavior property visible on derived with base and other behaviors through accessor" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.baseAccessor" ), "BASE", "base property visible on derived with base and other behaviors through accessor" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.derivedBaseBehaviorOtherBehavior" ), "UpDaTeD", "derived property after initialization on derived with base and other behaviors" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.baseBehavior" ), "UpDaTeD", "base behavior property after initialization on derived with base and other behaviors" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.otherBehavior" ), "UpDaTeD", "other behavior property after initialization on derived with base and other behaviors" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.base" ), "UpDaTeD", "base property after initialization on derived with base and other behaviors" );
-
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.derivedBaseBehaviorOtherBehaviorAccessor" ), "UPDATED", "derived property after initialization on derived with base and other behaviors through accessor" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.baseBehaviorAccessor" ), "UPDATED", "base behavior property after initialization on derived with base and other behaviors through accessor" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.otherBehaviorAccessor" ), "UPDATED", "other behavior property after initialization on derived with base and other behaviors through accessor" );
- equal( vwf.execute( derivedBaseBehaviorOtherBehaviorID, "this.baseAccessor" ), "UPDATED", "base property after initialization on derived with base and other behaviors through accessor" );
-
- cleanup();
- start();
-
- } );
-
- } );
-
- asyncTest( "Inheritance through behavior with own inheritance", function() { // DerivedDerivedBehavior implements DerivedBehavior extends Base; DerivedBehavior extends BaseBehavior
- equal( vwf.execute( derivedDerivedBehaviorID, "this.derivedDerivedBehavior" ), "derivedDerivedBehavior", "derived property visible on derived with derived behavior" );
- equal( vwf.execute( derivedDerivedBehaviorID, "this.derivedBehavior" ), "derivedBehavior", "derived behavior property visible on derived with derived behavior" );
- equal( vwf.execute( derivedDerivedBehaviorID, "'baseBehavior' in this" ), false, "base behavior property not visible on derived with derived behavior (JavaScript binding)" );
- equal( vwf.getProperty( derivedDerivedBehaviorID, "baseBehavior" ), undefined, "base behavior property not visible on derived with derived behavior (kernel delegation)" );
- equal( vwf.execute( derivedDerivedBehaviorID, "this.base" ), "base", "base property visible on derived with derived behavior" );
-
- equal( vwf.execute( derivedDerivedBehaviorID, "this.derivedDerivedBehaviorAccessor" ), "DERIVEDDERIVEDBEHAVIOR", "derived property visible on derived with derived behavior through accessor" );
- equal( vwf.execute( derivedDerivedBehaviorID, "this.derivedBehaviorAccessor" ), "DERIVEDBEHAVIOR", "derived behavior property visible on derived with derived behavior through accessor" );
- equal( vwf.execute( derivedDerivedBehaviorID, "'baseBehaviorAccessor' in this" ), false, "base behavior property not visible on derived with derived behavior through accessor (JavaScript binding)" );
- // equal( vwf.getProperty( derivedDerivedBehaviorID, "baseBehaviorAccessor" ), undefined, "base behavior property not visible on derived with derived behavior through accessor (kernel delegation)" ); // TODO: would need to handle ignorePrototype in vwf.model.javascript.gettingProperty() to prevent accessor inheritance in behaviors
- equal( vwf.execute( derivedDerivedBehaviorID, "this.baseAccessor" ), "BASE", "base property visible on derived with derived behavior through accessor" );
- equal( vwf.execute( derivedDerivedBehaviorID, "this.derivedDerivedBehavior" ), "UpDaTeD", "derived property after initialization on derived with derived behavior" );
- equal( vwf.execute( derivedDerivedBehaviorID, "this.derivedBehavior" ), "UpDaTeD", "derived behavior property after initialization on derived with derived behavior" );
- equal( vwf.execute( derivedDerivedBehaviorID, "'baseBehavior' in this" ), true, "base behavior property created on derived with derived behavior (JavaScript binding)" ); // TODO: kernel doesn't prevent this yet
- equal( vwf.getProperty( derivedDerivedBehaviorID, "baseBehavior" ), "CrEaTeD", "base behavior property created on derived with derived behavior (kernel delegation)" ); // TODO: kernel doesn't prevent this yet
- equal( vwf.execute( derivedDerivedBehaviorID, "this.base" ), "UpDaTeD", "base property after initialization on derived with derived behavior" );
-
- equal( vwf.execute( derivedDerivedBehaviorID, "this.derivedDerivedBehaviorAccessor" ), "UPDATED", "derived property after initialization on derived with derived behavior through accessor" );
- equal( vwf.execute( derivedDerivedBehaviorID, "this.derivedBehaviorAccessor" ), "UPDATED", "derived behavior property after initialization on derived with derived behavior through accessor" );
- equal( vwf.execute( derivedDerivedBehaviorID, "'baseBehaviorAccessor' in this" ), false, "base behavior property not initialized on derived with derived behavior through accessor (JavaScript binding)" );
- // equal( vwf.getProperty( derivedDerivedBehaviorID, "baseBehaviorAccessor" ), undefined, "base behavior property not initialized on derived with derived behavior through accessor (kernel delegation)" ); // TODO: would need to handle ignorePrototype in vwf.model.javascript.gettingProperty() to prevent accessor inheritance in behaviors
- equal( vwf.execute( derivedDerivedBehaviorID, "this.baseAccessor" ), "UPDATED", "base property after initialization on derived with derived behavior through accessor" );