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. Merges [42582] to the 4.9 branch. Fixes #42643. Built from https://develop.svn.wordpress.org/branches/4.9@42583 git-svn-id: http://core.svn.wordpress.org/branches/4.9@42412 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5220bad266
commit
723d0f2669
|
@ -1,4 +1,4 @@
|
||||||
/* global _wpmejsSettings */
|
/* global _wpmejsSettings, mejsL10n */
|
||||||
(function( window, $ ) {
|
(function( window, $ ) {
|
||||||
|
|
||||||
window.wp = window.wp || {};
|
window.wp = window.wp || {};
|
||||||
|
@ -42,6 +42,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.
|
// Only initialize new media elements.
|
||||||
$( '.wp-audio-shortcode, .wp-video-shortcode' )
|
$( '.wp-audio-shortcode, .wp-video-shortcode' )
|
||||||
.not( '.mejs-container' )
|
.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
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.9.3-alpha-42580';
|
$wp_version = '4.9.3-alpha-42583';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue