]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/mediaelement/wp-mediaelement.js
WordPress 4.3
[autoinstalls/wordpress.git] / wp-includes / js / mediaelement / wp-mediaelement.js
index fb09e3cde33095a43a5720a09c22d59fbf4cfec8..8c4364aa329a23bcccd9a38c992490f80ff3b09d 100644 (file)
@@ -1,3 +1,4 @@
+/* global mejs, _wpmejsSettings */
 (function ($) {
        // add mime-type aliases to MediaElement plugin support
        mejs.plugins.silverlight[0].types.push('video/x-ms-wmv');
@@ -6,8 +7,26 @@
        $(function () {
                var settings = {};
 
-               if ( typeof _wpmejsSettings !== 'undefined' )
-                       settings.pluginPath = _wpmejsSettings.pluginPath;
+               if ( typeof _wpmejsSettings !== 'undefined' ) {
+                       settings = _wpmejsSettings;
+               }
+
+               settings.success = settings.success || function (mejs) {
+                       var autoplay, loop;
+
+                       if ( 'flash' === mejs.pluginType ) {
+                               autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
+                               loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop;
+
+                               autoplay && mejs.addEventListener( 'canplay', function () {
+                                       mejs.play();
+                               }, false );
+
+                               loop && mejs.addEventListener( 'ended', function () {
+                                       mejs.play();
+                               }, false );
+                       }
+               };
 
                $('.wp-audio-shortcode, .wp-video-shortcode').mediaelementplayer( settings );
        });