Move removePlayer()
and unsetPlayer()
to wp.media.mixin
so that other classes can take advantage of them.
* `removePlayer()` is an alternative to MediaElement's player removal method that does not re-add the audio|video element back to the DOM. * `unsetPlayer()` will check for an existing `player` property on the passed instance and pause all players before calling `unsetPlayer()` See #27389. git-svn-id: https://develop.svn.wordpress.org/trunk@27538 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3d244e1fed
commit
2ba763c9ba
@ -305,6 +305,53 @@
|
|||||||
window.mejs.players[p].pause();
|
window.mejs.players[p].pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the MediaElement method for removing a player.
|
||||||
|
* MediaElement tries to pull the audio/video tag out of
|
||||||
|
* its container and re-add it to the DOM.
|
||||||
|
*/
|
||||||
|
removePlayer: function() {
|
||||||
|
var t = this.player, featureIndex, feature;
|
||||||
|
|
||||||
|
// invoke features cleanup
|
||||||
|
for ( featureIndex in t.options.features ) {
|
||||||
|
feature = t.options.features[featureIndex];
|
||||||
|
if ( t['clean' + feature] ) {
|
||||||
|
try {
|
||||||
|
t['clean' + feature](t);
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! t.isDynamic ) {
|
||||||
|
t.$node.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( 'native' !== t.media.pluginType ) {
|
||||||
|
t.media.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
delete window.mejs.players[t.id];
|
||||||
|
|
||||||
|
t.container.remove();
|
||||||
|
t.globalUnbind();
|
||||||
|
delete t.node.player;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows any class that has set 'player' to a MediaElementPlayer
|
||||||
|
* instance to remove the player when listening to events.
|
||||||
|
*
|
||||||
|
* Examples: modal closes, shortcode properties are removed, etc.
|
||||||
|
*/
|
||||||
|
unsetPlayer : function() {
|
||||||
|
if ( this.player ) {
|
||||||
|
wp.media.mixin.pauseAllPlayers();
|
||||||
|
wp.media.mixin.removePlayer.apply( this );
|
||||||
|
this.player = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6547,11 +6547,11 @@
|
|||||||
*/
|
*/
|
||||||
media.view.MediaDetails = media.view.Settings.AttachmentDisplay.extend({
|
media.view.MediaDetails = media.view.Settings.AttachmentDisplay.extend({
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
_.bindAll(this, 'success', 'unsetPlayer');
|
_.bindAll(this, 'success');
|
||||||
|
|
||||||
this.listenTo( this.controller, 'close', this.unsetPlayer );
|
this.listenTo( this.controller, 'close', media.mixin.unsetPlayer );
|
||||||
this.on( 'ready', this.setPlayer );
|
this.on( 'ready', this.setPlayer );
|
||||||
this.on( 'media:setting:remove', this.unsetPlayer );
|
this.on( 'media:setting:remove', media.mixin.unsetPlayer, this );
|
||||||
this.on( 'media:setting:remove', this.render );
|
this.on( 'media:setting:remove', this.render );
|
||||||
this.on( 'media:setting:remove', this.setPlayer );
|
this.on( 'media:setting:remove', this.setPlayer );
|
||||||
this.events = _.extend( this.events, {
|
this.events = _.extend( this.events, {
|
||||||
@ -6606,49 +6606,6 @@
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Override the MediaElement method for removing a player.
|
|
||||||
* MediaElement tries to pull the audio/video tag out of
|
|
||||||
* its container and re-add it to the DOM.
|
|
||||||
*/
|
|
||||||
removePlayer: function() {
|
|
||||||
var t = this.player, featureIndex, feature;
|
|
||||||
|
|
||||||
// invoke features cleanup
|
|
||||||
for ( featureIndex in t.options.features ) {
|
|
||||||
feature = t.options.features[featureIndex];
|
|
||||||
if ( t['clean' + feature] ) {
|
|
||||||
try {
|
|
||||||
t['clean' + feature](t);
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! t.isDynamic ) {
|
|
||||||
t.$node.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( 'native' !== t.media.pluginType ) {
|
|
||||||
t.media.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
delete window.mejs.players[t.id];
|
|
||||||
|
|
||||||
t.container.remove();
|
|
||||||
t.globalUnbind();
|
|
||||||
delete t.node.player;
|
|
||||||
},
|
|
||||||
|
|
||||||
unsetPlayer : function() {
|
|
||||||
if ( this.player ) {
|
|
||||||
if ( _.isUndefined( this.mejs.pluginType ) ) {
|
|
||||||
this.mejs.pause();
|
|
||||||
}
|
|
||||||
this.removePlayer();
|
|
||||||
this.player = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
success : function (mejs) {
|
success : function (mejs) {
|
||||||
var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
|
var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user