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.



git-svn-id: https://develop.svn.wordpress.org/trunk@28364 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2014-05-11 02:06:36 +00:00
parent 487da46928
commit 9705736cdf
2 changed files with 20 additions and 6 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 = [];

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' );