Ticket #27608: 27608.diff
File 27608.diff, 4.1 KB (added by , 11 years ago) |
---|
-
src/wp-includes/js/mediaelement/wp-playlist.js
4 4 "use strict"; 5 5 6 6 var WPPlaylistView = Backbone.View.extend({ 7 index : 0,8 9 itemTemplate : wp.template('wp-playlist-item'),10 11 7 initialize : function (options) { 12 var settings = {};13 8 this.index = 0; 9 this.settings = {}; 14 10 this.data = options.metadata || $.parseJSON( this.$('script').html() ); 15 11 this.playerNode = this.$( this.data.type ); 16 12 … … 18 14 this.current = this.tracks.first(); 19 15 20 16 if ( 'audio' === this.data.type ) { 21 this.currentTemplate = wp.template( 'wp-playlist-current-item');17 this.currentTemplate = wp.template( 'wp-playlist-current-item' ); 22 18 this.currentNode = this.$( '.wp-playlist-current-item' ); 23 19 } 24 20 … … 25 21 this.renderCurrent(); 26 22 27 23 if ( this.data.tracklist ) { 24 this.itemTemplate = wp.template( 'wp-playlist-item' ); 28 25 this.playingClass = 'wp-playlist-playing'; 29 26 this.renderTracks(); 30 27 } 31 28 32 this.playerNode.attr( 'src', this.current.get( 'src') );29 this.playerNode.attr( 'src', this.current.get( 'src' ) ); 33 30 34 _.bindAll( this, 'bindPlayer', ' ended', 'clickTrack' );31 _.bindAll( this, 'bindPlayer', 'bindResetPlayer', 'setPlayer', 'ended', 'clickTrack' ); 35 32 36 33 if ( ! _.isUndefined( window._wpmejsSettings ) ) { 37 settings.pluginPath = _wpmejsSettings.pluginPath;34 this.settings.pluginPath = _wpmejsSettings.pluginPath; 38 35 } 39 settings.success = this.bindPlayer; 36 this.settings.success = this.bindPlayer; 37 this.setPlayer(); 38 }, 40 39 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 ); 42 43 }, 43 44 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 44 70 renderCurrent : function () { 45 71 var dimensions; 46 72 if ( 'video' === this.data.type ) { … … 79 105 'click .wp-playlist-prev' : 'prev' 80 106 }, 81 107 82 bindPlayer : function (mejs) {83 this.player = mejs;84 this.player.addEventListener( 'ended', this.ended );85 },86 87 108 clickTrack : function (e) { 88 109 this.index = this.$( '.wp-playlist-item' ).index( e.currentTarget ); 89 110 this.setCurrent(); … … 110 131 }, 111 132 112 133 loadCurrent : function () { 134 var last = this.playerNode.attr( 'src' ).split('.').pop(), 135 current = this.current.get( 'src' ).split('.').pop(); 136 113 137 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 } 117 145 }, 118 146 119 147 setCurrent : function () { … … 127 155 } 128 156 129 157 this.loadCurrent(); 130 this.player.play();131 158 } 132 159 }); 133 160 -
src/wp-includes/media.php
2529 2529 'suggestedWidth' => __( 'Suggested width is %d pixels.' ), 2530 2530 'suggestedHeight' => __( 'Suggested height is %d pixels.' ), 2531 2531 2532 'mediaHTML5Text' => __( 'Add alternate sources for maximum HTML5 playback:' ),2533 2534 2532 // Edit Audio 2535 2533 'audioDetailsTitle' => __( 'Audio Details' ), 2536 2534 'audioReplaceTitle' => __( 'Replace Audio' ),