Changeset 34346
- Timestamp:
- 09/20/2015 03:16:23 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/mediaelement/wp-mediaelement.js
r31471 r34346 1 1 /* global mejs, _wpmejsSettings */ 2 (function ($) { 2 (function( window, $ ) { 3 4 window.wp = window.wp || {}; 5 3 6 // add mime-type aliases to MediaElement plugin support 4 7 mejs.plugins.silverlight[0].types.push('video/x-ms-wmv'); 5 8 mejs.plugins.silverlight[0].types.push('audio/x-ms-wma'); 6 9 7 $(function() {10 function wpMediaElement() { 8 11 var settings = {}; 9 12 10 if ( typeof _wpmejsSettings !== 'undefined' ) { 11 settings = _wpmejsSettings; 13 /** 14 * Initialize media elements. 15 * 16 * Ensures media elements that have already been initialized won't be 17 * processed again. 18 * 19 * @since 4.4.0 20 */ 21 function initialize() { 22 if ( typeof _wpmejsSettings !== 'undefined' ) { 23 settings = _wpmejsSettings; 24 } 25 26 settings.success = settings.success || function (mejs) { 27 var autoplay, loop; 28 29 if ( 'flash' === mejs.pluginType ) { 30 autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay; 31 loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop; 32 33 autoplay && mejs.addEventListener( 'canplay', function () { 34 mejs.play(); 35 }, false ); 36 37 loop && mejs.addEventListener( 'ended', function () { 38 mejs.play(); 39 }, false ); 40 } 41 }; 42 43 // Only initialize new media elements. 44 $( '.wp-audio-shortcode, .wp-video-shortcode' ) 45 .not( '.mejs-container' ) 46 .filter(function () { 47 return ! $( this ).parent().hasClass( '.mejs-mediaelement' ); 48 }) 49 .mediaelementplayer( settings ); 12 50 } 13 51 14 settings.success = settings.success || function (mejs) { 15 var autoplay, loop; 52 return { 53 initialize: initialize 54 }; 55 } 16 56 17 if ( 'flash' === mejs.pluginType ) { 18 autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay; 19 loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop; 57 window.wp.mediaelement = new wpMediaElement(); 20 58 21 autoplay && mejs.addEventListener( 'canplay', function () { 22 mejs.play(); 23 }, false ); 59 $( document ).on( 'ready', window.wp.mediaelement.initialize ); 24 60 25 loop && mejs.addEventListener( 'ended', function () { 26 mejs.play(); 27 }, false ); 28 } 29 }; 30 31 $('.wp-audio-shortcode, .wp-video-shortcode').mediaelementplayer( settings ); 32 }); 33 34 }(jQuery)); 61 })( window, jQuery );
Note: See TracChangeset
for help on using the changeset viewer.