PK ! ZCw" " wp-playlist.jsnu [ /* global _wpmejsSettings, MediaElementPlayer */ (function ($, _, Backbone) { 'use strict'; /** @namespace wp */ window.wp = window.wp || {}; var WPPlaylistView = Backbone.View.extend(/** @lends WPPlaylistView.prototype */{ /** * @constructs * * @param {Object} options The options to create this playlist view with. * @param {Object} options.metadata The metadata */ initialize : function (options) { this.index = 0; this.settings = {}; this.data = options.metadata || $.parseJSON( this.$('script.wp-playlist-script').html() ); this.playerNode = this.$( this.data.type ); this.tracks = new Backbone.Collection( this.data.tracks ); this.current = this.tracks.first(); if ( 'audio' === this.data.type ) { this.currentTemplate = wp.template( 'wp-playlist-current-item' ); this.currentNode = this.$( '.wp-playlist-current-item' ); } this.renderCurrent(); if ( this.data.tracklist ) { this.itemTemplate = wp.template( 'wp-playlist-item' ); this.playingClass = 'wp-playlist-playing'; this.renderTracks(); } this.playerNode.attr( 'src', this.current.get( 'src' ) ); _.bindAll( this, 'bindPlayer', 'bindResetPlayer', 'setPlayer', 'ended', 'clickTrack' ); if ( ! _.isUndefined( window._wpmejsSettings ) ) { this.settings = _.clone( _wpmejsSettings ); } this.settings.success = this.bindPlayer; this.setPlayer(); }, bindPlayer : function (mejs) { this.mejs = mejs; this.mejs.addEventListener( 'ended', this.ended ); }, bindResetPlayer : function (mejs) { this.bindPlayer( mejs ); this.playCurrentSrc(); }, setPlayer: function (force) { if ( this.player ) { this.player.pause(); this.player.remove(); this.playerNode = this.$( this.data.type ); } if (force) { this.playerNode.attr( 'src', this.current.get( 'src' ) ); this.settings.success = this.bindResetPlayer; } // This is also our bridge to the outside world. this.player = new MediaElementPlayer( this.playerNode.get(0), this.settings ); }, playCurrentSrc : function () { this.renderCurrent(); this.mejs.setSrc( this.playerNode.attr( 'src' ) ); this.mejs.load(); this.mejs.play(); }, renderCurrent : function () { var dimensions, defaultImage = 'wp-includes/images/media/video.svg'; if ( 'video' === this.data.type ) { if ( this.data.images && this.current.get( 'image' ) && -1 === this.current.get( 'image' ).src.indexOf( defaultImage ) ) { this.playerNode.attr( 'poster', this.current.get( 'image' ).src ); } dimensions = this.current.get( 'dimensions' ); if ( dimensions && dimensions.resized ) { this.playerNode.attr( dimensions.resized ); } } else { if ( ! this.data.images ) { this.current.set( 'image', false ); } this.currentNode.html( this.currentTemplate( this.current.toJSON() ) ); } }, renderTracks : function () { var self = this, i = 1, tracklist = $( '
' ); this.tracks.each(function (model) { if ( ! self.data.images ) { model.set( 'image', false ); } model.set( 'artists', self.data.artists ); model.set( 'index', self.data.tracknumbers ? i : false ); tracklist.append( self.itemTemplate( model.toJSON() ) ); i += 1; }); this.$el.append( tracklist ); this.$( '.wp-playlist-item' ).eq(0).addClass( this.playingClass ); }, events : { 'click .wp-playlist-item' : 'clickTrack', 'click .wp-playlist-next' : 'next', 'click .wp-playlist-prev' : 'prev' }, clickTrack : function (e) { e.preventDefault(); this.index = this.$( '.wp-playlist-item' ).index( e.currentTarget ); this.setCurrent(); }, ended : function () { if ( this.index + 1 < this.tracks.length ) { this.next(); } else { this.index = 0; this.setCurrent(); } }, next : function () { this.index = this.index + 1 >= this.tracks.length ? 0 : this.index + 1; this.setCurrent(); }, prev : function () { this.index = this.index - 1 < 0 ? this.tracks.length - 1 : this.index - 1; this.setCurrent(); }, loadCurrent : function () { var last = this.playerNode.attr( 'src' ) && this.playerNode.attr( 'src' ).split('.').pop(), current = this.current.get( 'src' ).split('.').pop(); this.mejs && this.mejs.pause(); if ( last !== current ) { this.setPlayer( true ); } else { this.playerNode.attr( 'src', this.current.get( 'src' ) ); this.playCurrentSrc(); } }, setCurrent : function () { this.current = this.tracks.at( this.index ); if ( this.data.tracklist ) { this.$( '.wp-playlist-item' ) .removeClass( this.playingClass ) .eq( this.index ) .addClass( this.playingClass ); } this.loadCurrent(); } }); /** * Initialize media playlists in the document. * * Only initializes new playlists not previously-initialized. * * @since 4.9.3 * @return {void} */ function initialize() { $( '.wp-playlist:not(:has(.mejs-container))' ).each( function() { new WPPlaylistView( { el: this } ); } ); } /** * Expose the API publicly on window.wp.playlist. * * @namespace wp.playlist * @since 4.9.3 * @type {object} */ window.wp.playlist = { initialize: initialize }; $( document ).ready( initialize ); window.WPPlaylistView = WPPlaylistView; }(jQuery, _, Backbone)); PK ! TXt mediaelement-migrate.jsnu [ /* global console, MediaElementPlayer, mejs */ (function ( window, $ ) { // Reintegrate `plugins` since they don't exist in MEJS anymore; it won't affect anything in the player if (mejs.plugins === undefined) { mejs.plugins = {}; mejs.plugins.silverlight = []; mejs.plugins.silverlight.push({ types: [] }); } // Inclusion of old `HtmlMediaElementShim` if it doesn't exist mejs.HtmlMediaElementShim = mejs.HtmlMediaElementShim || { getTypeFromFile: mejs.Utils.getTypeFromFile }; // Add missing global variables for backward compatibility if (mejs.MediaFeatures === undefined) { mejs.MediaFeatures = mejs.Features; } if (mejs.Utility === undefined) { mejs.Utility = mejs.Utils; } /** * Create missing variables and have default `classPrefix` overridden to avoid issues. * * `media` is now a fake wrapper needed to simplify manipulation of various media types, * so in order to access the `video` or `audio` tag, use `media.originalNode` or `player.node`; * `player.container` used to be jQuery but now is a HTML element, and many elements inside * the player rely on it being a HTML now, so its conversion is difficult; however, a * `player.$container` new variable has been added to be used as jQuery object */ var init = MediaElementPlayer.prototype.init; MediaElementPlayer.prototype.init = function () { this.options.classPrefix = 'mejs-'; this.$media = this.$node = $( this.node ); init.call( this ); }; var ready = MediaElementPlayer.prototype._meReady; MediaElementPlayer.prototype._meReady = function () { this.container = $( this.container) ; this.controls = $( this.controls ); this.layers = $( this.layers ); ready.apply( this, arguments ); }; // Override method so certain elements can be called with jQuery MediaElementPlayer.prototype.getElement = function ( el ) { return $ !== undefined && el instanceof $ ? el[0] : el; }; // Add jQuery ONLY to most of custom features' arguments for backward compatibility; default features rely 100% // on the arguments being HTML elements to work properly MediaElementPlayer.prototype.buildfeatures = function ( player, controls, layers, media ) { var defaultFeatures = [ 'playpause', 'current', 'progress', 'duration', 'tracks', 'volume', 'fullscreen' ]; for (var i = 0, total = this.options.features.length; i < total; i++) { var feature = this.options.features[i]; if (this['build' + feature]) { try { // Use jQuery for non-default features if (defaultFeatures.indexOf(feature) === -1) { this['build' + feature]( player, $(controls), $(layers), media ); } else { this['build' + feature]( player, controls, layers, media ); } } catch (e) { console.error( 'error building ' + feature, e ); } } } }; })( window, jQuery ); PK ! V wp-mediaelement.jsnu [ /* global _wpmejsSettings, mejsL10n */ (function( window, $ ) { window.wp = window.wp || {}; function wpMediaElement() { var settings = {}; /** * Initialize media elements. * * Ensures media elements that have already been initialized won't be * processed again. * * @memberOf wp.mediaelement * * @since 4.4.0 * * @return {void} */ function initialize() { var selectors = []; if ( typeof _wpmejsSettings !== 'undefined' ) { settings = $.extend( true, {}, _wpmejsSettings ); } settings.classPrefix = 'mejs-'; settings.success = settings.success || function ( mejs ) { var autoplay, loop; if ( mejs.rendererName && -1 !== mejs.rendererName.indexOf( 'flash' ) ) { autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay; loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop; if ( autoplay ) { mejs.addEventListener( 'canplay', function() { mejs.play(); }, false ); } if ( loop ) { mejs.addEventListener( 'ended', function() { mejs.play(); }, false ); } } }; /** * 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. * @return {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 '' + mejsL10n.strings['mejs.download-file'] + ''; } }; if ( 'undefined' === typeof settings.videoShortcodeLibrary || 'mediaelement' === settings.videoShortcodeLibrary ) { selectors.push( '.wp-video-shortcode' ); } if ( 'undefined' === typeof settings.audioShortcodeLibrary || 'mediaelement' === settings.audioShortcodeLibrary ) { selectors.push( '.wp-audio-shortcode' ); } if ( ! selectors.length ) { return; } // Only initialize new media elements. $( selectors.join( ', ' ) ) .not( '.mejs-container' ) .filter(function () { return ! $( this ).parent().hasClass( 'mejs-mediaelement' ); }) .mediaelementplayer( settings ); } return { initialize: initialize }; } /** * @namespace wp.mediaelement * @memberOf wp */ window.wp.mediaelement = new wpMediaElement(); $( window.wp.mediaelement.initialize ); })( window, jQuery ); PK ! A mediaelement.min.jsnu [ /*! * MediaElement.js * http://www.mediaelementjs.com/ * * Wrapper that mimics native HTML5 MediaElement (audio and video) * using a variety of technologies (pure JavaScript, Flash, iframe) * * Copyright 2010-2017, John Dyer (http://j.hn/) * License: MIT * */ !function i(o,l,s){function d(n,e){if(!l[n]){if(!o[n]){var t="function"==typeof require&&require;if(!e&&t)return t(n,!0);if(u)return u(n,!0);var r=new Error("Cannot find module '"+n+"'");throw r.code="MODULE_NOT_FOUND",r}var a=l[n]={exports:{}};o[n][0].call(a.exports,function(e){var t=o[n][1][e];return d(t||e)},a,a.exports,i,o,l,s)}return l[n].exports}for(var u="function"==typeof require&&require,e=0;e