When pausing "all" players attached to MCE views, don't reach into global scope and pause "every" player. Only pause the players bound to MCE views.

Fixes #27971.


Built from https://develop.svn.wordpress.org/trunk@28364


git-svn-id: http://core.svn.wordpress.org/trunk@28192 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-05-11 02:07:14 +00:00
parent fb1aab6520
commit 37b7f39e95
4 changed files with 22 additions and 8 deletions

View File

@ -371,7 +371,7 @@ window.wp = window.wp || {};
self = this,
frame, data, callback;
wp.media.mixin.pauseAllPlayers();
$( document ).trigger( 'media:edit' );
data = window.decodeURIComponent( $( node ).attr('data-wpview-text') );
frame = media.edit( data );
@ -407,8 +407,10 @@ window.wp = window.wp || {};
initialize: function( options ) {
this.players = [];
this.shortcode = options.shortcode;
_.bindAll( this, 'setPlayer' );
$(this).on( 'ready', this.setPlayer );
_.bindAll( this, 'setPlayer', 'pausePlayers' );
$( this ).on( 'ready', this.setPlayer );
$( 'body' ).on( 'click', '.wp-switch-editor', this.pausePlayers );
$( document ).on( 'media:edit', this.pausePlayers );
},
/**
@ -524,6 +526,10 @@ window.wp = window.wp || {};
this.data = {};
this.attachments = [];
this.shortcode = options.shortcode;
$( 'body' ).on( 'click', '.wp-switch-editor', this.pausePlayers );
$( document ).on( 'media:edit', this.pausePlayers );
this.fetch();
},
@ -687,8 +693,8 @@ window.wp = window.wp || {};
},
unbind: function() {
var self = this;
this.pauseAllPlayers();
_.each( this.players, function ( player ) {
player.pause();
self.removePlayer( player );
} );
this.players = [];

File diff suppressed because one or more lines are too long

View File

@ -26,6 +26,15 @@
}
},
/**
* Pauses the current object's instances of MediaElementPlayer
*/
pausePlayers: function() {
_.each( this.players, function (player) {
player.pause();
} );
},
/**
* Utility to identify the user's browser
*/
@ -168,8 +177,8 @@
*/
unsetPlayers : function() {
if ( this.players && this.players.length ) {
wp.media.mixin.pauseAllPlayers();
_.each( this.players, function (player) {
player.pause();
wp.media.mixin.removePlayer( player );
} );
this.players = [];
@ -911,7 +920,6 @@
*/
function init() {
$(document.body)
.on( 'click', '.wp-switch-editor', wp.media.mixin.pauseAllPlayers )
.on( 'click', '.add-media-source', function( e ) {
media.frame.lastMime = $( e.currentTarget ).data( 'mime' );
media.frame.setState( 'add-' + media.frame.defaults.id + '-source' );

File diff suppressed because one or more lines are too long