Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

62 righe
1.5 KiB

  1. /* global mejs, _wpmejsSettings */
  2. (function( window, $ ) {
  3. window.wp = window.wp || {};
  4. // add mime-type aliases to MediaElement plugin support
  5. mejs.plugins.silverlight[0].types.push('video/x-ms-wmv');
  6. mejs.plugins.silverlight[0].types.push('audio/x-ms-wma');
  7. function wpMediaElement() {
  8. var settings = {};
  9. /**
  10. * Initialize media elements.
  11. *
  12. * Ensures media elements that have already been initialized won't be
  13. * processed again.
  14. *
  15. * @since 4.4.0
  16. */
  17. function initialize() {
  18. if ( typeof _wpmejsSettings !== 'undefined' ) {
  19. settings = $.extend( true, {}, _wpmejsSettings );
  20. }
  21. settings.success = settings.success || function (mejs) {
  22. var autoplay, loop;
  23. if ( 'flash' === mejs.pluginType ) {
  24. autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
  25. loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop;
  26. autoplay && mejs.addEventListener( 'canplay', function () {
  27. mejs.play();
  28. }, false );
  29. loop && mejs.addEventListener( 'ended', function () {
  30. mejs.play();
  31. }, false );
  32. }
  33. };
  34. // Only initialize new media elements.
  35. $( '.wp-audio-shortcode, .wp-video-shortcode' )
  36. .not( '.mejs-container' )
  37. .filter(function () {
  38. return ! $( this ).parent().hasClass( '.mejs-mediaelement' );
  39. })
  40. .mediaelementplayer( settings );
  41. }
  42. return {
  43. initialize: initialize
  44. };
  45. }
  46. window.wp.mediaelement = new wpMediaElement();
  47. $( window.wp.mediaelement.initialize );
  48. })( window, jQuery );