Make WordPress Core

Ticket #27608: 27608.diff

File 27608.diff, 4.1 KB (added by wonderboymusic, 11 years ago)
  • src/wp-includes/js/mediaelement/wp-playlist.js

     
    44        "use strict";
    55
    66        var WPPlaylistView = Backbone.View.extend({
    7                 index : 0,
    8 
    9                 itemTemplate : wp.template('wp-playlist-item'),
    10 
    117                initialize : function (options) {
    12                         var settings = {};
    13 
     8                        this.index = 0;
     9                        this.settings = {};
    1410                        this.data = options.metadata || $.parseJSON( this.$('script').html() );
    1511                        this.playerNode = this.$( this.data.type );
    1612
     
    1814                        this.current = this.tracks.first();
    1915
    2016                        if ( 'audio' === this.data.type ) {
    21                                 this.currentTemplate = wp.template('wp-playlist-current-item');
     17                                this.currentTemplate = wp.template( 'wp-playlist-current-item' );
    2218                                this.currentNode = this.$( '.wp-playlist-current-item' );
    2319                        }
    2420
     
    2521                        this.renderCurrent();
    2622
    2723                        if ( this.data.tracklist ) {
     24                                this.itemTemplate = wp.template( 'wp-playlist-item' );
    2825                                this.playingClass = 'wp-playlist-playing';
    2926                                this.renderTracks();
    3027                        }
    3128
    32                         this.playerNode.attr( 'src', this.current.get('src') );
     29                        this.playerNode.attr( 'src', this.current.get( 'src' ) );
    3330
    34                         _.bindAll( this, 'bindPlayer', 'ended', 'clickTrack' );
     31                        _.bindAll( this, 'bindPlayer', 'bindResetPlayer', 'setPlayer', 'ended', 'clickTrack' );
    3532
    3633                        if ( ! _.isUndefined( window._wpmejsSettings ) ) {
    37                                 settings.pluginPath = _wpmejsSettings.pluginPath;
     34                                this.settings.pluginPath = _wpmejsSettings.pluginPath;
    3835                        }
    39                         settings.success = this.bindPlayer;
     36                        this.settings.success = this.bindPlayer;
     37                        this.setPlayer();
     38                },
    4039
    41                         this._player = new MediaElementPlayer( this.playerNode.get(0), settings );
     40                bindPlayer : function (mejs) {
     41                        this.player = mejs;
     42                        this.player.addEventListener( 'ended', this.ended );
    4243                },
    4344
     45                bindResetPlayer : function (mejs) {
     46                        this.bindPlayer( mejs );
     47                        this.playCurrentSrc();
     48                },
     49
     50                setPlayer: function () {
     51                        if ( this._player ) {
     52                                this._player.pause();
     53                                this._player.remove();
     54                                this.playerNode = this.$( this.data.type );
     55                                this.playerNode.prop( 'src', this.current.get( 'src' ) );
     56                                this.settings.success = this.bindResetPlayer;
     57                        }
     58                        /**
     59                         * This is also our bridge to the outside world
     60                         */
     61                        this._player = new MediaElementPlayer( this.playerNode.get(0), this.settings );
     62                },
     63
     64                playCurrentSrc : function () {
     65                        this.renderCurrent();
     66                        this.player.load();
     67                        this.player.play();
     68                },
     69
    4470                renderCurrent : function () {
    4571                        var dimensions;
    4672                        if ( 'video' === this.data.type ) {
     
    79105                        'click .wp-playlist-prev' : 'prev'
    80106                },
    81107
    82                 bindPlayer : function (mejs) {
    83                         this.player = mejs;
    84                         this.player.addEventListener( 'ended', this.ended );
    85                 },
    86 
    87108                clickTrack : function (e) {
    88109                        this.index = this.$( '.wp-playlist-item' ).index( e.currentTarget );
    89110                        this.setCurrent();
     
    110131                },
    111132
    112133                loadCurrent : function () {
     134                        var last = this.playerNode.attr( 'src' ).split('.').pop(),
     135                                current = this.current.get( 'src' ).split('.').pop();
     136
    113137                        this.player.pause();
    114                         this.playerNode.attr( 'src', this.current.get( 'src' ) );
    115                         this.renderCurrent();
    116                         this.player.load();
     138
     139                        if ( last !== current ) {
     140                                this.setPlayer();
     141                        } else {
     142                                this.playerNode.prop( 'src', this.current.get( 'src' ) );
     143                                this.playCurrentSrc();
     144                        }
    117145                },
    118146
    119147                setCurrent : function () {
     
    127155                        }
    128156
    129157                        this.loadCurrent();
    130                         this.player.play();
    131158                }
    132159        });
    133160
  • src/wp-includes/media.php

     
    25292529                'suggestedWidth' => __( 'Suggested width is %d pixels.' ),
    25302530                'suggestedHeight' => __( 'Suggested height is %d pixels.' ),
    25312531
    2532                 'mediaHTML5Text'        => __( 'Add alternate sources for maximum HTML5 playback:' ),
    2533 
    25342532                // Edit Audio
    25352533                'audioDetailsTitle'     => __( 'Audio Details' ),
    25362534                'audioReplaceTitle'     => __( 'Replace Audio' ),