[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 /* global console, MediaElementPlayer, mejs */ 2 (function ( window, $ ) { 3 // Reintegrate `plugins` since they don't exist in MEJS anymore; it won't affect anything in the player 4 if (mejs.plugins === undefined) { 5 mejs.plugins = {}; 6 mejs.plugins.silverlight = []; 7 mejs.plugins.silverlight.push({ 8 types: [] 9 }); 10 } 11 12 // Inclusion of old `HtmlMediaElementShim` if it doesn't exist 13 mejs.HtmlMediaElementShim = mejs.HtmlMediaElementShim || { 14 getTypeFromFile: mejs.Utils.getTypeFromFile 15 }; 16 17 // Add missing global variables for backward compatibility 18 if (mejs.MediaFeatures === undefined) { 19 mejs.MediaFeatures = mejs.Features; 20 } 21 if (mejs.Utility === undefined) { 22 mejs.Utility = mejs.Utils; 23 } 24 25 /** 26 * Create missing variables and have default `classPrefix` overridden to avoid issues. 27 * 28 * `media` is now a fake wrapper needed to simplify manipulation of various media types, 29 * so in order to access the `video` or `audio` tag, use `media.originalNode` or `player.node`; 30 * `player.container` used to be jQuery but now is a HTML element, and many elements inside 31 * the player rely on it being a HTML now, so its conversion is difficult; however, a 32 * `player.$container` new variable has been added to be used as jQuery object 33 */ 34 var init = MediaElementPlayer.prototype.init; 35 MediaElementPlayer.prototype.init = function () { 36 this.options.classPrefix = 'mejs-'; 37 this.$media = this.$node = $( this.node ); 38 init.call( this ); 39 }; 40 41 var ready = MediaElementPlayer.prototype._meReady; 42 MediaElementPlayer.prototype._meReady = function () { 43 this.container = $( this.container) ; 44 this.controls = $( this.controls ); 45 this.layers = $( this.layers ); 46 ready.apply( this, arguments ); 47 }; 48 49 // Override method so certain elements can be called with jQuery 50 MediaElementPlayer.prototype.getElement = function ( el ) { 51 return $ !== undefined && el instanceof $ ? el[0] : el; 52 }; 53 54 // Add jQuery ONLY to most of custom features' arguments for backward compatibility; default features rely 100% 55 // on the arguments being HTML elements to work properly 56 MediaElementPlayer.prototype.buildfeatures = function ( player, controls, layers, media ) { 57 var defaultFeatures = [ 58 'playpause', 59 'current', 60 'progress', 61 'duration', 62 'tracks', 63 'volume', 64 'fullscreen' 65 ]; 66 for (var i = 0, total = this.options.features.length; i < total; i++) { 67 var feature = this.options.features[i]; 68 if (this['build' + feature]) { 69 try { 70 // Use jQuery for non-default features 71 if (defaultFeatures.indexOf(feature) === -1) { 72 this['build' + feature]( player, $(controls), $(layers), media ); 73 } else { 74 this['build' + feature]( player, controls, layers, media ); 75 } 76 77 } catch (e) { 78 console.error( 'error building ' + feature, e ); 79 } 80 } 81 } 82 }; 83 84 })( window, jQuery );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |