WordPress/wp-includes/js/mediaelement/wp-mediaelement.js
Weston Ruter 7af3b92736 Media: Upgrade MediaElement.js from 2.22.0 to 4.2.3.
Props rafa8626, grosbouff, westonruter, azaozz, Plastikschnitzer for testing.
See #39686.

Built from https://develop.svn.wordpress.org/trunk@41198


git-svn-id: http://core.svn.wordpress.org/trunk@41038 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-01 04:43:51 +00:00

64 lines
1.5 KiB
JavaScript

/* global _wpmejsSettings */
(function( window, $ ) {
window.wp = window.wp || {};
function wpMediaElement() {
var settings = {};
/**
* Initialize media elements.
*
* Ensures media elements that have already been initialized won't be
* processed again.
*
* @since 4.4.0
*
* @returns {void}
*/
function initialize() {
if ( typeof _wpmejsSettings !== 'undefined' ) {
settings = $.extend( true, {}, _wpmejsSettings );
}
settings.classPrefix = 'mejs-';
settings.success = settings.success || function (mejs) {
var autoplay, loop;
if ( mejs.rendererName && -1 !== mejs.rendererName.indexOf( 'flash' ) ) {
autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop;
if ( autoplay ) {
mejs.addEventListener( 'canplay', function() {
mejs.play();
}, false );
}
if ( loop ) {
mejs.addEventListener( 'ended', function() {
mejs.play();
}, false );
}
}
};
// Only initialize new media elements.
$( '.wp-audio-shortcode, .wp-video-shortcode' )
.not( '.mejs-container' )
.filter(function () {
return ! $( this ).parent().hasClass( 'mejs-mediaelement' );
})
.mediaelementplayer( settings );
}
return {
initialize: initialize
};
}
window.wp.mediaelement = new wpMediaElement();
$( window.wp.mediaelement.initialize );
})( window, jQuery );