2013-11-15 01:52:09 -05:00
|
|
|
/* global mejs, _wpmejsSettings */
|
2015-09-19 23:17:24 -04:00
|
|
|
(function( window, $ ) {
|
|
|
|
|
|
|
|
window.wp = window.wp || {};
|
|
|
|
|
2013-03-16 01:25:44 -04:00
|
|
|
// add mime-type aliases to MediaElement plugin support
|
|
|
|
mejs.plugins.silverlight[0].types.push('video/x-ms-wmv');
|
|
|
|
mejs.plugins.silverlight[0].types.push('audio/x-ms-wma');
|
|
|
|
|
2015-09-19 23:17:24 -04:00
|
|
|
function wpMediaElement() {
|
2013-08-01 09:15:14 -04:00
|
|
|
var settings = {};
|
|
|
|
|
2015-09-19 23:17:24 -04:00
|
|
|
/**
|
|
|
|
* Initialize media elements.
|
|
|
|
*
|
|
|
|
* Ensures media elements that have already been initialized won't be
|
|
|
|
* processed again.
|
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
*/
|
|
|
|
function initialize() {
|
|
|
|
if ( typeof _wpmejsSettings !== 'undefined' ) {
|
2016-01-20 10:47:28 -05:00
|
|
|
settings = $.extend( true, {}, _wpmejsSettings );
|
2015-09-19 23:17:24 -04:00
|
|
|
}
|
2014-05-10 21:28:15 -04:00
|
|
|
|
2015-09-19 23:17:24 -04:00
|
|
|
settings.success = settings.success || function (mejs) {
|
|
|
|
var autoplay, loop;
|
|
|
|
|
|
|
|
if ( 'flash' === mejs.pluginType ) {
|
|
|
|
autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
|
|
|
|
loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop;
|
|
|
|
|
|
|
|
autoplay && mejs.addEventListener( 'canplay', function () {
|
|
|
|
mejs.play();
|
|
|
|
}, false );
|
|
|
|
|
|
|
|
loop && mejs.addEventListener( 'ended', function () {
|
|
|
|
mejs.play();
|
|
|
|
}, false );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Only initialize new media elements.
|
|
|
|
$( '.wp-audio-shortcode, .wp-video-shortcode' )
|
|
|
|
.not( '.mejs-container' )
|
|
|
|
.filter(function () {
|
2017-05-12 16:53:45 -04:00
|
|
|
return ! $( this ).parent().hasClass( 'mejs-mediaelement' );
|
2015-09-19 23:17:24 -04:00
|
|
|
})
|
|
|
|
.mediaelementplayer( settings );
|
|
|
|
}
|
2014-05-10 21:28:15 -04:00
|
|
|
|
2015-09-19 23:17:24 -04:00
|
|
|
return {
|
|
|
|
initialize: initialize
|
2014-03-07 00:52:14 -05:00
|
|
|
};
|
2015-09-19 23:17:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
window.wp.mediaelement = new wpMediaElement();
|
2013-08-01 09:15:14 -04:00
|
|
|
|
2016-01-13 12:39:25 -05:00
|
|
|
$( window.wp.mediaelement.initialize );
|
2013-03-16 01:25:44 -04:00
|
|
|
|
2015-09-19 23:17:24 -04:00
|
|
|
})( window, jQuery );
|