Ticket #25077: 25077.diff
File 25077.diff, 6.4 KB (added by , 11 years ago) |
---|
-
src/wp-includes/js/media-views.js
6370 6370 }); 6371 6371 6372 6372 /** 6373 * wp.media.view. AudioDetails6373 * wp.media.view.MediaDetails 6374 6374 * 6375 6375 * @contructor 6376 6376 * @augments wp.media.view.Settings.AttachmentDisplay … … 6379 6379 * @augments wp.Backbone.View 6380 6380 * @augments Backbone.View 6381 6381 */ 6382 media.view.AudioDetails = media.view.Settings.AttachmentDisplay.extend({ 6383 className: 'audio-details', 6384 template: media.template('audio-details'), 6385 6382 media.view.MediaDetails = media.view.Settings.AttachmentDisplay.extend({ 6386 6383 initialize: function() { 6387 _.bindAll(this, ' player', 'close');6384 _.bindAll(this, 'success', 'close'); 6388 6385 6389 6386 this.listenTo( this.controller, 'close', this.close ); 6390 6387 … … 6403 6400 }, this.options ); 6404 6401 }, 6405 6402 6403 prepareSrc : function (media) { 6404 media.src = [ 6405 media.src, 6406 media.src.indexOf('?') > -1 ? '&' : '?', 6407 (new Date()).getTime() 6408 ].join(''); 6409 6410 return media; 6411 }, 6412 6413 setPlayer : function () { 6414 this.player = false; 6415 }, 6416 6417 /** 6418 * Override the MediaElement method for removing a player. 6419 * MediaElement tries to pull the audio/video tag out of 6420 * its container and re-add it to the DOM. 6421 * 6422 */ 6423 remove: function() { 6424 var t = this.player, featureIndex, feature; 6425 6426 // invoke features cleanup 6427 for ( featureIndex in t.options.features ) { 6428 feature = t.options.features[featureIndex]; 6429 if ( t['clean' + feature] ) { 6430 try { 6431 t['clean' + feature](t); 6432 } catch (e) {} 6433 } 6434 } 6435 6436 if ( ! t.isDynamic ) { 6437 t.$node.remove(); 6438 } 6439 6440 if ( 'native' !== t.media.pluginType ) { 6441 t.media.remove(); 6442 } 6443 6444 delete mejs.players[t.id]; 6445 6446 t.container.remove(); 6447 t.globalUnbind(); 6448 delete t.node.player; 6449 }, 6450 6406 6451 close : function() { 6407 this.mejs.pause(); 6452 if ( this.player ) { 6453 this.mejs.pause(); 6454 this.remove(); 6455 } 6408 6456 }, 6409 6457 6410 player : function (mejs) { 6458 success : function (mejs) { 6459 var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay; 6460 6461 if ( 'flash' === mejs.pluginType && autoplay ) { 6462 mejs.addEventListener( 'canplay', function () { 6463 mejs.play(); 6464 }, false ); 6465 } 6466 6411 6467 this.mejs = mejs; 6412 6468 }, 6413 6469 6414 6470 render: function() { 6415 6471 var self = this, settings = { 6416 success : this. player6472 success : this.success 6417 6473 }; 6418 6474 6419 6475 if ( ! _.isUndefined( window._wpmejsSettings ) ) { … … 6423 6479 media.view.Settings.AttachmentDisplay.prototype.render.apply( this, arguments ); 6424 6480 setTimeout( function() { self.resetFocus(); }, 10 ); 6425 6481 6426 new MediaElementPlayer( this.$('.wp-audio-shortcode').get(0),settings );6482 this.setPlayer( settings ); 6427 6483 6428 6484 return this; 6429 6485 }, … … 6434 6490 }); 6435 6491 6436 6492 /** 6437 * wp.media.view. VideoDetails6493 * wp.media.view.AudioDetails 6438 6494 * 6439 6495 * @contructor 6496 * @augments wp.media.view.MediaDetails 6440 6497 * @augments wp.media.view.Settings.AttachmentDisplay 6441 6498 * @augments wp.media.view.Settings 6442 6499 * @augments wp.media.View 6443 6500 * @augments wp.Backbone.View 6444 6501 * @augments Backbone.View 6445 6502 */ 6446 media.view. VideoDetails = media.view.Settings.AttachmentDisplay.extend({6447 className: ' video-details',6448 template: media.template(' video-details'),6503 media.view.AudioDetails = media.view.MediaDetails.extend({ 6504 className: 'audio-details', 6505 template: media.template('audio-details'), 6449 6506 6450 initialize: function() {6451 _.bindAll(this, 'success');6507 setPlayer: function( settings ) { 6508 var audio = this.$('.wp-audio-shortcode').get(0); 6452 6509 6453 this.listenTo( this.controller, 'close', this.close);6510 audio = this.prepareSrc( audio ); 6454 6511 6455 media.view.Settings.AttachmentDisplay.prototype.initialize.apply( this, arguments ); 6456 }, 6512 this.player = new MediaElementPlayer( audio, settings ); 6513 return this; 6514 } 6515 }); 6457 6516 6458 prepare: function() { 6459 var attachment = false; 6517 /** 6518 * wp.media.view.VideoDetails 6519 * 6520 * @contructor 6521 * @augments wp.media.view.MediaDetails 6522 * @augments wp.media.view.Settings.AttachmentDisplay 6523 * @augments wp.media.view.Settings 6524 * @augments wp.media.View 6525 * @augments wp.Backbone.View 6526 * @augments Backbone.View 6527 */ 6528 media.view.VideoDetails = media.view.MediaDetails.extend({ 6529 className: 'video-details', 6530 template: media.template('video-details'), 6460 6531 6461 if ( this.model.attachment ) { 6462 attachment = this.model.attachment.toJSON(); 6463 } 6464 return _.defaults({ 6465 model: this.model.toJSON(), 6466 attachment: attachment 6467 }, this.options ); 6468 }, 6532 setPlayer: function( settings ) { 6533 var video = this.$('.wp-video-shortcode').get(0); 6469 6534 6470 close : function() { 6471 this.mejs.pause(); 6472 this.player.remove(); 6473 }, 6535 video = this.prepareSrc( video ); 6474 6536 6475 success : function (mejs) {6476 this.mejs = mejs;6477 },6478 6479 render: function() {6480 var video, self = this, settings = {6481 success : this.success6482 };6483 6484 if ( ! _.isUndefined( window._wpmejsSettings ) ) {6485 settings.pluginPath = _wpmejsSettings.pluginPath;6486 }6487 6488 media.view.Settings.AttachmentDisplay.prototype.render.apply( this, arguments );6489 setTimeout( function() { self.resetFocus(); }, 10 );6490 6491 video = this.$('.wp-video-shortcode').get(0);6492 video.src = [6493 video.src,6494 video.src.indexOf('?') > -1 ? '&' : '?',6495 (new Date()).getTime()6496 ].join('');6497 6498 6537 this.player = new MediaElementPlayer( video, settings ); 6499 6538 return this; 6500 },6501 6502 resetFocus: function() {6503 this.$( '.embed-media-settings' ).scrollTop( 0 );6504 6539 } 6505 6540 }); 6506 6541 -
src/wp-includes/js/mediaelement/wp-mediaelement.js
7 7 $(function () { 8 8 var settings = {}; 9 9 10 if ( typeof _wpmejsSettings !== 'undefined' ) 10 if ( typeof _wpmejsSettings !== 'undefined' ) { 11 11 settings.pluginPath = _wpmejsSettings.pluginPath; 12 } 12 13 14 settings.success = function (mejs) { 15 var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay; 16 if ( 'flash' === mejs.pluginType && autoplay ) { 17 mejs.addEventListener( 'canplay', function () { 18 mejs.play(); 19 }, false ); 20 } 21 }; 22 13 23 $('.wp-audio-shortcode, .wp-video-shortcode').mediaelementplayer( settings ); 14 24 }); 15 25