~canonical-sysadmins/wordpress/4.6

« back to all changes in this revision

Viewing changes to wp-includes/js/mediaelement/wp-mediaelement.js

  • Committer: Jacek Nykis
  • Date: 2015-01-05 16:17:05 UTC
  • Revision ID: jacek.nykis@canonical.com-20150105161705-w544l1h5mcg7u4w9
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* global mejs, _wpmejsSettings */
 
2
(function ($) {
 
3
        // add mime-type aliases to MediaElement plugin support
 
4
        mejs.plugins.silverlight[0].types.push('video/x-ms-wmv');
 
5
        mejs.plugins.silverlight[0].types.push('audio/x-ms-wma');
 
6
 
 
7
        $(function () {
 
8
                var settings = {};
 
9
 
 
10
                if ( typeof _wpmejsSettings !== 'undefined' ) {
 
11
                        settings = _wpmejsSettings;
 
12
                }
 
13
 
 
14
                settings.success = function (mejs) {
 
15
                        var autoplay, loop;
 
16
 
 
17
                        if ( 'flash' === mejs.pluginType ) {
 
18
                                autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
 
19
                                loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop;
 
20
 
 
21
                                autoplay && mejs.addEventListener( 'canplay', function () {
 
22
                                        mejs.play();
 
23
                                }, false );
 
24
 
 
25
                                loop && mejs.addEventListener( 'ended', function () {
 
26
                                        mejs.play();
 
27
                                }, false );
 
28
                        }
 
29
                };
 
30
 
 
31
                $('.wp-audio-shortcode, .wp-video-shortcode').mediaelementplayer( settings );
 
32
        });
 
33
 
 
34
}(jQuery));