Media: Introduce a custom error handler for MediaElement.js to display a download link if a FLV file cannot be rendered for any reason.
Props Clorith. Fixes #42643. Built from https://develop.svn.wordpress.org/trunk@42582 git-svn-id: http://core.svn.wordpress.org/trunk@42411 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8a884f562a
commit
3429cfeabe
|
@ -1,4 +1,4 @@
|
|||
/* global _wpmejsSettings */
|
||||
/* global _wpmejsSettings, mejsL10n */
|
||||
(function( window, $ ) {
|
||||
|
||||
window.wp = window.wp || {};
|
||||
|
@ -44,6 +44,25 @@
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Custom error handler.
|
||||
*
|
||||
* Sets up a custom error handler in case a video render fails, and provides a download
|
||||
* link as the fallback.
|
||||
*
|
||||
* @since 4.9.3
|
||||
*
|
||||
* @param {object} media The wrapper that mimics all the native events/properties/methods for all renderers.
|
||||
* @param {object} node The original HTML video, audio, or iframe tag where the media was loaded.
|
||||
* @returns {string}
|
||||
*/
|
||||
settings.customError = function ( media, node ) {
|
||||
// Make sure we only fall back to a download link for flash files.
|
||||
if ( -1 !== media.rendererName.indexOf( 'flash' ) || -1 !== media.rendererName.indexOf( 'flv' ) ) {
|
||||
return '<a href="' + node.src + '">' + mejsL10n.strings['mejs.download-video'] + '</a>';
|
||||
}
|
||||
};
|
||||
|
||||
// Only initialize new media elements.
|
||||
$( '.wp-audio-shortcode, .wp-video-shortcode' )
|
||||
.not( '.mejs-container' )
|
||||
|
|
|
@ -1 +1 @@
|
|||
!function(a,b){function c(){function a(){"undefined"!=typeof _wpmejsSettings&&(c=b.extend(!0,{},_wpmejsSettings)),c.classPrefix="mejs-",c.success=c.success||function(a){var b,c;a.rendererName&&-1!==a.rendererName.indexOf("flash")&&(b=a.attributes.autoplay&&"false"!==a.attributes.autoplay,c=a.attributes.loop&&"false"!==a.attributes.loop,b&&a.addEventListener("canplay",function(){a.play()},!1),c&&a.addEventListener("ended",function(){a.play()},!1))},b(".wp-audio-shortcode, .wp-video-shortcode").not(".mejs-container").filter(function(){return!b(this).parent().hasClass("mejs-mediaelement")}).mediaelementplayer(c)}var c={};return{initialize:a}}a.wp=a.wp||{},a.wp.mediaelement=new c,b(a.wp.mediaelement.initialize)}(window,jQuery);
|
||||
!function(a,b){function c(){function a(){"undefined"!=typeof _wpmejsSettings&&(c=b.extend(!0,{},_wpmejsSettings)),c.classPrefix="mejs-",c.success=c.success||function(a){var b,c;a.rendererName&&-1!==a.rendererName.indexOf("flash")&&(b=a.attributes.autoplay&&"false"!==a.attributes.autoplay,c=a.attributes.loop&&"false"!==a.attributes.loop,b&&a.addEventListener("canplay",function(){a.play()},!1),c&&a.addEventListener("ended",function(){a.play()},!1))},c.customError=function(a,b){if(-1!==a.rendererName.indexOf("flash")||-1!==a.rendererName.indexOf("flv"))return'<a href="'+b.src+'">'+mejsL10n.strings["mejs.download-video"]+"</a>"},b(".wp-audio-shortcode, .wp-video-shortcode").not(".mejs-container").filter(function(){return!b(this).parent().hasClass("mejs-mediaelement")}).mediaelementplayer(c)}var c={};return{initialize:a}}a.wp=a.wp||{},a.wp.mediaelement=new c,b(a.wp.mediaelement.initialize)}(window,jQuery);
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0-alpha-42581';
|
||||
$wp_version = '5.0-alpha-42582';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue