wp/wp-includes/js/mediaelement/wp-mediaelement.js
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
--- a/wp/wp-includes/js/mediaelement/wp-mediaelement.js	Mon Jun 08 16:11:51 2015 +0000
+++ b/wp/wp-includes/js/mediaelement/wp-mediaelement.js	Tue Jun 09 03:35:32 2015 +0200
@@ -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 );
 	});