mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-07 11:20:28 +01:00
2e602a8560
* Introduces `mediaelement-migrate.js`. * Upgrades ME.js from 4.2.5-74e01a40 to 4.2.6-78496d1. Props rafa8626, bradyvercher. See #39686. Fixes #42189. Built from https://develop.svn.wordpress.org/trunk@41877 git-svn-id: http://core.svn.wordpress.org/trunk@41711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
64 lines
1.5 KiB
JavaScript
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 );
|