1 /* global mejs, _wpmejsSettings */
2 (function( window, $ ) {
4 window.wp = window.wp || {};
6 // add mime-type aliases to MediaElement plugin support
7 mejs.plugins.silverlight[0].types.push('video/x-ms-wmv');
8 mejs.plugins.silverlight[0].types.push('audio/x-ms-wma');
10 function wpMediaElement() {
14 * Initialize media elements.
16 * Ensures media elements that have already been initialized won't be
21 function initialize() {
22 if ( typeof _wpmejsSettings !== 'undefined' ) {
23 settings = $.extend( true, {}, _wpmejsSettings );
26 settings.success = settings.success || function (mejs) {
29 if ( 'flash' === mejs.pluginType ) {
30 autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
31 loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop;
33 autoplay && mejs.addEventListener( 'canplay', function () {
37 loop && mejs.addEventListener( 'ended', function () {
43 // Only initialize new media elements.
44 $( '.wp-audio-shortcode, .wp-video-shortcode' )
45 .not( '.mejs-container' )
47 return ! $( this ).parent().hasClass( '.mejs-mediaelement' );
49 .mediaelementplayer( settings );
53 initialize: initialize
57 window.wp.mediaelement = new wpMediaElement();
59 $( window.wp.mediaelement.initialize );