<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[27478] trunk/src/wp-includes: Audio/Video shortcodes in the media modal:</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/27478">27478</a></dd>
<dt>Author</dt> <dd>wonderboymusic</dd>
<dt>Date</dt> <dd>2014-03-09 05:24:10 +0000 (Sun, 09 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Audio/Video shortcodes in the media modal:

* Make a generic model, `wp.media.model.PostMedia`, which replaces `wp.media.model.PostAudio` and `wp.media.model.PostVideo`
* Make a generic library, `wp.media.controller.MediaLibrary`, which replaces `wp.media.controller.ReplaceVideo` and `wp.media.controller.ReplaceAudio`
* `wp.media.controller.MediaLibrary` is used to create new states that want to load a library filtered by type, making it incredibly simple to add states to frames. See `wp.media.view.MediaFrame.VideoDetails` and `wp.media.view.MediaFrame.AudioDetails`.

UX changes:

* Add the ability to manage HTML5 fallbacks - add additional `<source>`s or remove specific `<source>`s
* In the Video Details state, add the ability to select a poster image

See <a href="http://core.trac.wordpress.org/ticket/27016">#27016</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesjsmediamodelsjs">trunk/src/wp-includes/js/media-models.js</a></li>
<li><a href="#trunksrcwpincludesjsmediaviewsjs">trunk/src/wp-includes/js/media-views.js</a></li>
<li><a href="#trunksrcwpincludesjsmediaelementwpmediaelementcss">trunk/src/wp-includes/js/mediaelement/wp-mediaelement.css</a></li>
<li><a href="#trunksrcwpincludesjstinymcepluginswpgallerypluginjs">trunk/src/wp-includes/js/tinymce/plugins/wpgallery/plugin.js</a></li>
<li><a href="#trunksrcwpincludesmediatemplatephp">trunk/src/wp-includes/media-template.php</a></li>
<li><a href="#trunksrcwpincludesmediaphp">trunk/src/wp-includes/media.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesjsmediamodelsjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/media-models.js (27477 => 27478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/media-models.js 2014-03-09 01:05:48 UTC (rev 27477)
+++ trunk/src/wp-includes/js/media-models.js    2014-03-09 05:24:10 UTC (rev 27478)
</span><span class="lines">@@ -453,57 +453,32 @@
</span><span class="cx">  });
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * wp.media.model.PostAudio
</del><ins>+         * wp.media.model.PostMedia
</ins><span class="cx">    *
</span><span class="cx">   * @constructor
</span><span class="cx">   * @augments Backbone.Model
</span><span class="cx">   **/
</span><del>-       media.model.PostAudio = Backbone.Model.extend({
</del><ins>+        media.model.PostMedia = Backbone.Model.extend({
</ins><span class="cx">           initialize: function() {
</span><span class="cx">                  this.attachment = false;
</span><span class="cx">          },
</span><span class="cx"> 
</span><del>-               changeAttachment: function( attachment ) {
-                       var self = this;
-
</del><ins>+                setSource: function ( attachment ) {
</ins><span class="cx">                   this.attachment = attachment;
</span><span class="cx">                  this.extension = attachment.get('filename' ).split('.').pop();
</span><span class="cx"> 
</span><span class="cx">                  if ( _.contains( wp.media.view.settings.embedExts, this.extension ) ) {
</span><del>-                               this.set( this.extension, attachment.get( 'url' ) );
</del><ins>+                                this.set( this.extension, this.attachment.get( 'url' ) );
</ins><span class="cx">                   } else {
</span><span class="cx">                          this.unset( this.extension );
</span><span class="cx">                  }
</span><del>-
-                       _.each( _.without( wp.media.view.settings.embedExts, this.extension ), function (ext) {
-                               self.unset( ext );
-                       } );
-               }
-       });
-
-       /**
-        * wp.media.model.PostVideo
-        *
-        * @constructor
-        * @augments Backbone.Model
-        **/
-       media.model.PostVideo = Backbone.Model.extend({
-               initialize: function() {
-                       this.attachment = false;
</del><span class="cx">           },
</span><span class="cx"> 
</span><span class="cx">          changeAttachment: function( attachment ) {
</span><span class="cx">                  var self = this;
</span><span class="cx"> 
</span><del>-                       this.attachment = attachment;
-                       this.extension = attachment.get('filename' ).split('.').pop();
</del><ins>+                        this.setSource( attachment );
</ins><span class="cx"> 
</span><del>-                       if ( _.contains( wp.media.view.settings.embedExts, this.extension ) ) {
-                               this.set( this.extension, attachment.get( 'url' ) );
-                       } else {
-                               this.unset( this.extension );
-                       }
-
</del><span class="cx">                   _.each( _.without( wp.media.view.settings.embedExts, this.extension ), function (ext) {
</span><span class="cx">                          self.unset( ext );
</span><span class="cx">                  } );
</span></span></pre></div>
<a id="trunksrcwpincludesjsmediaviewsjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/media-views.js (27477 => 27478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/media-views.js  2014-03-09 01:05:48 UTC (rev 27477)
+++ trunk/src/wp-includes/js/media-views.js     2014-03-09 05:24:10 UTC (rev 27478)
</span><span class="lines">@@ -786,7 +786,7 @@
</span><span class="cx">          }, media.controller.Library.prototype.defaults ),
</span><span class="cx"> 
</span><span class="cx">          initialize: function( options ) {
</span><del>-                       this.audio = options.audio;
</del><ins>+                        this.media = options.media;
</ins><span class="cx">                   media.controller.State.prototype.initialize.apply( this, arguments );
</span><span class="cx">          }
</span><span class="cx">  });
</span><span class="lines">@@ -812,7 +812,7 @@
</span><span class="cx">          }, media.controller.Library.prototype.defaults ),
</span><span class="cx"> 
</span><span class="cx">          initialize: function( options ) {
</span><del>-                       this.video = options.video;
</del><ins>+                        this.media = options.media;
</ins><span class="cx">                   media.controller.State.prototype.initialize.apply( this, arguments );
</span><span class="cx">          }
</span><span class="cx">  });
</span><span class="lines">@@ -1183,34 +1183,27 @@
</span><span class="cx">  _.extend( media.controller.EditImage.prototype, media.selectionSync );
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * wp.media.controller.ReplaceVideo
</del><ins>+         * wp.media.controller.MediaLibrary
</ins><span class="cx">    *
</span><del>-        * Replace a selected single video
-        *
</del><span class="cx">    * @constructor
</span><span class="cx">   * @augments wp.media.controller.Library
</span><span class="cx">   * @augments wp.media.controller.State
</span><span class="cx">   * @augments Backbone.Model
</span><span class="cx">   */
</span><del>-       media.controller.ReplaceVideo = media.controller.Library.extend({
</del><ins>+        media.controller.MediaLibrary = media.controller.Library.extend({
</ins><span class="cx">           defaults: _.defaults({
</span><del>-                       id:         'replace-video',
</del><span class="cx">                   filterable: 'uploaded',
</span><span class="cx">                  multiple:   false,
</span><del>-                       toolbar:    'replace',
-                       title:      l10n.replaceVideoTitle,
-                       priority:   60,
-                       syncSelection: false
</del><ins>+                        priority:   80,
+                       syncSelection: false,
+                       displaySettings: true
</ins><span class="cx">           }, media.controller.Library.prototype.defaults ),
</span><span class="cx"> 
</span><span class="cx">          initialize: function( options ) {
</span><span class="cx">                  var library, comparator;
</span><span class="cx"> 
</span><del>-                       this.video = options.video;
-                       // If we haven't been provided a `library`, create a `Selection`.
-                       if ( ! this.get('library') ) {
-                               this.set( 'library', media.query({ type: 'video' }) );
-                       }
</del><ins>+                        this.media = options.media;
+                       this.set( 'library', media.query({ type: options.type }) );
</ins><span class="cx"> 
</span><span class="cx">                  media.controller.Library.prototype.initialize.apply( this, arguments );
</span><span class="cx"> 
</span><span class="lines">@@ -1244,76 +1237,10 @@
</span><span class="cx"> 
</span><span class="cx">          updateSelection: function() {
</span><span class="cx">                  var selection = this.get('selection'),
</span><del>-                               attachment = this.video.attachment;
</del><ins>+                                attachment;
</ins><span class="cx"> 
</span><del>-                       selection.reset( attachment ? [ attachment ] : [] );
-               }
-       });
</del><ins>+                        attachment = this.media.attachment;
</ins><span class="cx"> 
</span><del>-       /**
-        * wp.media.controller.ReplaceAudio
-        *
-        * Replace a selected single audio file
-        *
-        * @constructor
-        * @augments wp.media.controller.Library
-        * @augments wp.media.controller.State
-        * @augments Backbone.Model
-        */
-       media.controller.ReplaceAudio = media.controller.Library.extend({
-               defaults: _.defaults({
-                       id:         'replace-audio',
-                       filterable: 'uploaded',
-                       multiple:   false,
-                       toolbar:    'replace',
-                       title:      l10n.replaceAudioTitle,
-                       priority:   60,
-                       syncSelection: false
-               }, media.controller.Library.prototype.defaults ),
-
-               initialize: function( options ) {
-                       var library, comparator;
-
-                       this.audio = options.audio;
-                       // If we haven't been provided a `library`, create a `Selection`.
-                       if ( ! this.get('library') ) {
-                               this.set( 'library', media.query({ type: 'audio' }) );
-                       }
-
-                       media.controller.Library.prototype.initialize.apply( this, arguments );
-
-                       library    = this.get('library');
-                       comparator = library.comparator;
-
-                       // Overload the library's comparator to push items that are not in
-                       // the mirrored query to the front of the aggregate collection.
-                       library.comparator = function( a, b ) {
-                               var aInQuery = !! this.mirroring.get( a.cid ),
-                                       bInQuery = !! this.mirroring.get( b.cid );
-
-                               if ( ! aInQuery && bInQuery ) {
-                                       return -1;
-                               } else if ( aInQuery && ! bInQuery ) {
-                                       return 1;
-                               } else {
-                                       return comparator.apply( this, arguments );
-                               }
-                       };
-
-                       // Add all items in the selection to the library, so any featured
-                       // images that are not initially loaded still appear.
-                       library.observe( this.get('selection') );
-               },
-
-               activate: function() {
-                       this.updateSelection();
-                       media.controller.Library.prototype.activate.apply( this, arguments );
-               },
-
-               updateSelection: function() {
-                       var selection = this.get('selection'),
-                               attachment = this.audio.attachment;
-
</del><span class="cx">                   selection.reset( attachment ? [ attachment ] : [] );
</span><span class="cx">          }
</span><span class="cx">  });
</span><span class="lines">@@ -2794,8 +2721,8 @@
</span><span class="cx">          },
</span><span class="cx"> 
</span><span class="cx">          initialize: function( options ) {
</span><del>-                       this.audio = new media.model.PostAudio( options.metadata );
-                       this.options.selection = new media.model.Selection( this.audio.attachment, { multiple: false } );
</del><ins>+                        this.media = new media.model.PostMedia( options.metadata );
+                       this.options.selection = new media.model.Selection( this.media.attachment, { multiple: false } );
</ins><span class="cx">                   media.view.MediaFrame.Select.prototype.initialize.apply( this, arguments );
</span><span class="cx">          },
</span><span class="cx"> 
</span><span class="lines">@@ -2806,35 +2733,44 @@
</span><span class="cx">                  this.on( 'menu:render:audio-details', this.renderMenu, this );
</span><span class="cx">                  this.on( 'toolbar:render:audio-details', this.renderAudioDetailsToolbar, this );
</span><span class="cx">                  // override the select toolbar
</span><del>-                       this.on( 'toolbar:render:replace', this.renderReplaceAudioToolbar, this );
</del><ins>+                        this.on( 'toolbar:render:replace-audio', this.renderReplaceAudioToolbar, this );
+                       this.on( 'toolbar:render:add-audio-source', this.renderAddAudioSourceToolbar, this );
</ins><span class="cx">           },
</span><span class="cx"> 
</span><span class="cx">          createStates: function() {
</span><span class="cx">                  this.states.add([
</span><del>-                               new media.controller.AudioDetails({
-                                       audio: this.audio,
</del><ins>+                                new media.controller.AudioDetails( {
+                                       media: this.media,
</ins><span class="cx">                                   editable: false,
</span><span class="cx">                                  menu: 'audio-details'
</span><del>-                               }),
-                               new media.controller.ReplaceAudio({
</del><ins>+                                } ),
+
+                               new media.controller.MediaLibrary( {
+                                       type: 'audio',
</ins><span class="cx">                                   id: 'replace-audio',
</span><del>-                                       library:   media.query( { type: 'audio' } ),
-                                       audio: this.audio,
-                                       multiple:  false,
-                                       title:     l10n.audioReplaceTitle,
-                                       menu: 'audio-details',
-                                       toolbar: 'replace',
-                                       priority:  80,
-                                       displaySettings: true
-                               })
</del><ins>+                                        title: l10n.audioReplaceTitle,
+                                       toolbar: 'replace-audio',
+                                       media: this.media,
+                                       menu: 'audio-details'
+                               } ),
+
+
+                               new media.controller.MediaLibrary( {
+                                       type: 'audio',
+                                       id: 'add-audio-source',
+                                       title: l10n.audioAddSourceTitle,
+                                       toolbar: 'add-audio-source',
+                                       media: this.media,
+                                       menu: 'audio-details'
+                               } )
</ins><span class="cx">                   ]);
</span><span class="cx">          },
</span><span class="cx"> 
</span><span class="cx">          renderAudioDetailsContent: function() {
</span><span class="cx">                  var view = new media.view.AudioDetails({
</span><span class="cx">                          controller: this,
</span><del>-                               model: this.state().audio,
-                               attachment: this.state().audio.attachment
</del><ins>+                                model: this.state().media,
+                               attachment: this.state().media.attachment
</ins><span class="cx">                   }).render();
</span><span class="cx"> 
</span><span class="cx">                  this.content.set( view );
</span><span class="lines">@@ -2880,9 +2816,7 @@
</span><span class="cx"> 
</span><span class="cx">                                                  controller.close();
</span><span class="cx"> 
</span><del>-                                                       // not sure if we want to use wp.media.string.image which will create a shortcode or
-                                                       // perhaps wp.html.string to at least to build the <img />
-                                                       state.trigger( 'update', controller.audio.toJSON() );
</del><ins>+                                                        state.trigger( 'update', controller.media.toJSON() );
</ins><span class="cx"> 
</span><span class="cx">                                                  // Restore and reset the default state.
</span><span class="cx">                                                  controller.setState( controller.options.state );
</span><span class="lines">@@ -2908,11 +2842,11 @@
</span><span class="cx">                                                          selection = state.get( 'selection' ),
</span><span class="cx">                                                          attachment = selection.single();
</span><span class="cx"> 
</span><del>-                                                       controller.audio.changeAttachment( attachment, state.display( attachment ) );
</del><ins>+                                                        controller.media.changeAttachment( attachment, state.display( attachment ) );
</ins><span class="cx"> 
</span><span class="cx">                                                  // not sure if we want to use wp.media.string.image which will create a shortcode or
</span><span class="cx">                                                  // perhaps wp.html.string to at least to build the <img />
</span><del>-                                                       state.trigger( 'replace', controller.audio.toJSON() );
</del><ins>+                                                        state.trigger( 'replace', controller.media.toJSON() );
</ins><span class="cx"> 
</span><span class="cx">                                                  // Restore and reset the default state.
</span><span class="cx">                                                  controller.setState( controller.options.state );
</span><span class="lines">@@ -2921,6 +2855,34 @@
</span><span class="cx">                                  }
</span><span class="cx">                          }
</span><span class="cx">                  }) );
</span><ins>+               },
+
+               renderAddAudioSourceToolbar: function() {
+                       this.toolbar.set( new media.view.Toolbar({
+                               controller: this,
+                               items: {
+                                       replace: {
+                                               style:    'primary',
+                                               text:     l10n.audioAddSourceTitle,
+                                               priority: 80,
+
+                                               click: function() {
+                                                       var controller = this.controller,
+                                                               state = controller.state(),
+                                                               selection = state.get( 'selection' ),
+                                                               attachment = selection.single();
+
+                                                       controller.media.setSource( attachment, state.display( attachment ) );
+
+                                                       state.trigger( 'add-source', controller.media.toJSON() );
+
+                                                       // Restore and reset the default state.
+                                                       controller.setState( controller.options.state );
+                                                       controller.reset();
+                                               }
+                                       }
+                               }
+                       }) );
</ins><span class="cx">           }
</span><span class="cx">  });
</span><span class="cx"> 
</span><span class="lines">@@ -2949,8 +2911,8 @@
</span><span class="cx">          },
</span><span class="cx"> 
</span><span class="cx">          initialize: function( options ) {
</span><del>-                       this.video = new media.model.PostVideo( options.metadata );
-                       this.options.selection = new media.model.Selection( this.video.attachment, { multiple: false } );
</del><ins>+                        this.media = new media.model.PostMedia( options.metadata );
+                       this.options.selection = new media.model.Selection( this.media.attachment, { multiple: false } );
</ins><span class="cx">                   media.view.MediaFrame.Select.prototype.initialize.apply( this, arguments );
</span><span class="cx">          },
</span><span class="cx"> 
</span><span class="lines">@@ -2961,35 +2923,53 @@
</span><span class="cx">                  this.on( 'menu:render:video-details', this.renderMenu, this );
</span><span class="cx">                  this.on( 'toolbar:render:video-details', this.renderVideoDetailsToolbar, this );
</span><span class="cx">                  // override the select toolbar
</span><del>-                       this.on( 'toolbar:render:replace', this.renderReplaceVideoToolbar, this );
</del><ins>+                        this.on( 'toolbar:render:replace-video', this.renderReplaceVideoToolbar, this );
+                       this.on( 'toolbar:render:add-video-source', this.renderAddVideoSourceToolbar, this );
+                       this.on( 'toolbar:render:select-poster-image', this.renderSelectPosterImageToolbar, this );
</ins><span class="cx">           },
</span><span class="cx"> 
</span><span class="cx">          createStates: function() {
</span><span class="cx">                  this.states.add([
</span><span class="cx">                          new media.controller.VideoDetails({
</span><del>-                                       video: this.video,
</del><ins>+                                        media: this.media,
</ins><span class="cx">                                   editable: false,
</span><span class="cx">                                  menu: 'video-details'
</span><span class="cx">                          }),
</span><del>-                               new media.controller.ReplaceVideo({
</del><ins>+
+                               new media.controller.MediaLibrary( {
+                                       type: 'video',
</ins><span class="cx">                                   id: 'replace-video',
</span><del>-                                       library:   media.query( { type: 'video' } ),
-                                       video: this.video,
-                                       multiple:  false,
-                                       title:     l10n.videoReplaceTitle,
-                                       menu: 'video-details',
-                                       toolbar: 'replace',
-                                       priority:  80,
-                                       displaySettings: true
-                               })
</del><ins>+                                        title: l10n.videoReplaceTitle,
+                                       toolbar: 'replace-video',
+                                       media: this.media,
+                                       menu: 'video-details'
+                               } ),
+
+                               new media.controller.MediaLibrary( {
+                                       type: 'video',
+                                       id: 'add-video-source',
+                                       title: l10n.videoAddSourceTitle,
+                                       toolbar: 'add-video-source',
+                                       media: this.media,
+                                       menu: 'video-details'
+                               } ),
+
+                               new media.controller.MediaLibrary( {
+                                       type: 'image',
+                                       id: 'select-poster-image',
+                                       title: l10n.videoSelectPosterImageTitle,
+                                       toolbar: 'select-poster-image',
+                                       media: this.media,
+                                       menu: 'video-details'
+                               } )
</ins><span class="cx">                   ]);
</span><span class="cx">          },
</span><span class="cx"> 
</span><span class="cx">          renderVideoDetailsContent: function() {
</span><span class="cx">                  var view = new media.view.VideoDetails({
</span><span class="cx">                          controller: this,
</span><del>-                               model: this.state().video,
-                               attachment: this.state().video.attachment
</del><ins>+                                model: this.state().media,
+                               attachment: this.state().media.attachment
</ins><span class="cx">                   }).render();
</span><span class="cx"> 
</span><span class="cx">                  this.content.set( view );
</span><span class="lines">@@ -3037,7 +3017,7 @@
</span><span class="cx"> 
</span><span class="cx">                                                  // not sure if we want to use wp.media.string.image which will create a shortcode or
</span><span class="cx">                                                  // perhaps wp.html.string to at least to build the <img />
</span><del>-                                                       state.trigger( 'update', controller.video.toJSON() );
</del><ins>+                                                        state.trigger( 'update', controller.media.toJSON() );
</ins><span class="cx"> 
</span><span class="cx">                                                  // Restore and reset the default state.
</span><span class="cx">                                                  controller.setState( controller.options.state );
</span><span class="lines">@@ -3063,9 +3043,9 @@
</span><span class="cx">                                                          selection = state.get( 'selection' ),
</span><span class="cx">                                                          attachment = selection.single();
</span><span class="cx"> 
</span><del>-                                                       controller.video.changeAttachment( attachment, state.display( attachment ) );
</del><ins>+                                                        controller.media.changeAttachment( attachment, state.display( attachment ) );
</ins><span class="cx"> 
</span><del>-                                                       state.trigger( 'replace', controller.video.toJSON() );
</del><ins>+                                                        state.trigger( 'replace', controller.media.toJSON() );
</ins><span class="cx"> 
</span><span class="cx">                                                  // Restore and reset the default state.
</span><span class="cx">                                                  controller.setState( controller.options.state );
</span><span class="lines">@@ -3074,6 +3054,62 @@
</span><span class="cx">                                  }
</span><span class="cx">                          }
</span><span class="cx">                  }) );
</span><ins>+               },
+
+               renderAddVideoSourceToolbar: function() {
+                       this.toolbar.set( new media.view.Toolbar({
+                               controller: this,
+                               items: {
+                                       replace: {
+                                               style:    'primary',
+                                               text:     l10n.videoAddSourceTitle,
+                                               priority: 80,
+
+                                               click: function() {
+                                                       var controller = this.controller,
+                                                               state = controller.state(),
+                                                               selection = state.get( 'selection' ),
+                                                               attachment = selection.single();
+
+                                                       controller.media.setSource( attachment, state.display( attachment ) );
+
+                                                       state.trigger( 'add-source', controller.media.toJSON() );
+
+                                                       // Restore and reset the default state.
+                                                       controller.setState( controller.options.state );
+                                                       controller.reset();
+                                               }
+                                       }
+                               }
+                       }) );
+               },
+
+               renderSelectPosterImageToolbar: function() {
+                       this.toolbar.set( new media.view.Toolbar({
+                               controller: this,
+                               items: {
+                                       replace: {
+                                               style:    'primary',
+                                               text:     l10n.videoSelectPosterImageTitle,
+                                               priority: 80,
+
+                                               click: function() {
+                                                       var controller = this.controller,
+                                                               state = controller.state(),
+                                                               selection = state.get( 'selection' ),
+                                                               attachment = selection.single();
+
+                                                       controller.media.set( 'poster', attachment.get( 'url' ) );
+
+                                                       state.trigger( 'set-poster-image', controller.media.toJSON() );
+
+                                                       // Restore and reset the default state.
+                                                       controller.setState( controller.options.state );
+                                                       controller.reset();
+                                               }
+                                       }
+                               }
+                       }) );
</ins><span class="cx">           }
</span><span class="cx">  });
</span><span class="cx"> 
</span><span class="lines">@@ -6415,10 +6451,16 @@
</span><span class="cx">   */
</span><span class="cx">  media.view.MediaDetails = media.view.Settings.AttachmentDisplay.extend({
</span><span class="cx">          initialize: function() {
</span><del>-                       _.bindAll(this, 'success', 'close');
</del><ins>+                        _.bindAll(this, 'success', 'unsetPlayer');
</ins><span class="cx"> 
</span><del>-                       this.listenTo( this.controller, 'close', this.close );
</del><ins>+                        this.listenTo( this.controller, 'close', this.unsetPlayer );
</ins><span class="cx">                   this.on( 'ready', this.setPlayer );
</span><ins>+                       this.on( 'media:setting:remove', this.unsetPlayer );
+                       this.on( 'media:setting:remove', this.render );
+                       this.on( 'media:setting:remove', this.setPlayer );
+                       this.events = _.extend( this.events, {
+                               'click .remove-setting' : 'removeSetting'
+                       } );
</ins><span class="cx"> 
</span><span class="cx">                  media.view.Settings.AttachmentDisplay.prototype.initialize.apply( this, arguments );
</span><span class="cx">          },
</span><span class="lines">@@ -6454,6 +6496,16 @@
</span><span class="cx">                  return media;
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               removeSetting : function (e) {
+                       var setting = $( e.currentTarget ).parent();
+
+                       this.model.unset( setting.find( 'input' ).data( 'setting' ) );
+
+                       setting.remove();
+
+                       this.trigger( 'media:setting:remove', this );
+               },
+
</ins><span class="cx">           setPlayer : function () {
</span><span class="cx">                  if ( ! this.player && this.media ) {
</span><span class="cx">                          this.player = new MediaElementPlayer( this.media, this.settings );
</span><span class="lines">@@ -6472,7 +6524,7 @@
</span><span class="cx">           *      MediaElement tries to pull the audio/video tag out of
</span><span class="cx">           *      its container and re-add it to the DOM.
</span><span class="cx">           */
</span><del>-               remove: function() {
</del><ins>+                removePlayer: function() {
</ins><span class="cx">                   var t = this.player, featureIndex, feature;
</span><span class="cx"> 
</span><span class="cx">                  // invoke features cleanup
</span><span class="lines">@@ -6500,12 +6552,12 @@
</span><span class="cx">                  delete t.node.player;
</span><span class="cx">          },
</span><span class="cx"> 
</span><del>-               close : function() {
</del><ins>+                unsetPlayer : function() {
</ins><span class="cx">                   if ( this.player ) {
</span><span class="cx">                          if ( _.isUndefined( this.mejs.pluginType ) ) {
</span><span class="cx">                                  this.mejs.pause();
</span><span class="cx">                          }
</span><del>-                               this.remove();
</del><ins>+                                this.removePlayer();
</ins><span class="cx">                           this.player = false;
</span><span class="cx">                  }
</span><span class="cx">          },
</span><span class="lines">@@ -6560,9 +6612,17 @@
</span><span class="cx">          template:  media.template('audio-details'),
</span><span class="cx"> 
</span><span class="cx">          setMedia: function() {
</span><del>-                       var audio = this.$('.wp-audio-shortcode').get(0);
</del><ins>+                        var audio = this.$('.wp-audio-shortcode');
</ins><span class="cx"> 
</span><del>-                       this.media = this.prepareSrc( audio );
</del><ins>+                        if ( audio.find( 'source' ).length ) {
+                               if ( audio.is(':hidden') ) {
+                                       audio.show();
+                               }
+                               this.media = this.prepareSrc( audio.get(0) );
+                       } else {
+                               audio.hide();
+                               this.media = false;
+                       }
</ins><span class="cx"> 
</span><span class="cx">                  return this;
</span><span class="cx">          }
</span><span class="lines">@@ -6586,14 +6646,21 @@
</span><span class="cx">          setMedia: function() {
</span><span class="cx">                  var video = this.$('.wp-video-shortcode');
</span><span class="cx"> 
</span><del>-                       if ( ! video.hasClass('youtube-video') ) {
-                               video = this.prepareSrc( video.get(0) );
</del><ins>+                        if ( video.find( 'source' ).length ) {
+                               if ( video.is(':hidden') ) {
+                                       video.show();
+                               }
+
+                               if ( ! video.hasClass('youtube-video') ) {
+                                       this.media = this.prepareSrc( video.get(0) );
+                               } else {
+                                       this.media = video.get(0);
+                               }
</ins><span class="cx">                   } else {
</span><del>-                               video = video.get(0);
</del><ins>+                                video.hide();
+                               this.media = false;
</ins><span class="cx">                   }
</span><span class="cx"> 
</span><del>-                       this.media = video;
-
</del><span class="cx">                   return this;
</span><span class="cx">          }
</span><span class="cx">  });
</span></span></pre></div>
<a id="trunksrcwpincludesjsmediaelementwpmediaelementcss"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/mediaelement/wp-mediaelement.css (27477 => 27478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/mediaelement/wp-mediaelement.css        2014-03-09 01:05:48 UTC (rev 27477)
+++ trunk/src/wp-includes/js/mediaelement/wp-mediaelement.css   2014-03-09 05:24:10 UTC (rev 27478)
</span><span class="lines">@@ -14,18 +14,33 @@
</span><span class="cx">  width: auto !important;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.audio-details .wp-audio-shortcode {
</del><ins>+.media-embed-details .wp-audio-shortcode {
</ins><span class="cx">   display: inline-block;
</span><span class="cx">  max-width: 400px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.video-details .embed-video-settings,
-.audio-details .embed-audio-settings {
-       top: 10px;
</del><ins>+.media-embed-details .embed-media-settings {
+       padding-top: 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-.video-details .embed-video-settings .checkbox-setting,
-.audio-details .embed-audio-settings .checkbox-setting {
</del><ins>+.media-embed-details .instructions {
+       padding: 16px;
+       max-width: 600px;
+}
+
+.media-embed-details .setting a {
+       color: #a00;
+}
+
+.media-embed-details .setting a:hover {
+       color: #f00;
+}
+
+.media-embed-details .embed-media-settings {
+       top: 70px;
+}
+
+.media-embed-details .embed-media-settings .checkbox-setting {
</ins><span class="cx">   width: 100px;
</span><span class="cx">  clear: none;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunksrcwpincludesjstinymcepluginswpgallerypluginjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/tinymce/plugins/wpgallery/plugin.js (27477 => 27478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/tinymce/plugins/wpgallery/plugin.js     2014-03-09 01:05:48 UTC (rev 27477)
+++ trunk/src/wp-includes/js/tinymce/plugins/wpgallery/plugin.js        2014-03-09 05:24:10 UTC (rev 27478)
</span><span class="lines">@@ -97,7 +97,7 @@
</span><span class="cx">                  frame.on( 'close', function () {
</span><span class="cx">                          frame.detach();
</span><span class="cx">                  } );
</span><del>-                       frame.state( 'video-details' ).on( 'update replace', function ( selection ) {
</del><ins>+                        frame.state( 'video-details' ).on( 'update replace add-source select-poster-image', function ( selection ) {
</ins><span class="cx">                           var shortcode = wp.media.video.shortcode( selection );
</span><span class="cx">                          editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) );
</span><span class="cx">                          frame.detach();
</span><span class="lines">@@ -108,7 +108,7 @@
</span><span class="cx">                  frame.on( 'close', function () {
</span><span class="cx">                          frame.detach();
</span><span class="cx">                  } );
</span><del>-                       frame.state( 'audio-details' ).on( 'update replace', function ( selection ) {
</del><ins>+                        frame.state( 'audio-details' ).on( 'update replace add-source', function ( selection ) {
</ins><span class="cx">                           var shortcode = wp.media.audio.shortcode( selection );
</span><span class="cx">                          editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) );
</span><span class="cx">                          frame.detach();
</span></span></pre></div>
<a id="trunksrcwpincludesmediatemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/media-template.php (27477 => 27478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/media-template.php 2014-03-09 01:05:48 UTC (rev 27477)
+++ trunk/src/wp-includes/media-template.php    2014-03-09 05:24:10 UTC (rev 27478)
</span><span class="lines">@@ -663,7 +663,8 @@
</span><span class="cx"> 
</span><span class="cx">  <script type="text/html" id="tmpl-audio-details">
</span><span class="cx">          <?php $audio_types = wp_get_audio_extensions(); ?>
</span><del>-               <div class="media-embed">
</del><ins>+                <div class="media-embed media-embed-details">
+                       <div class="instructions media-instructions">{{{ wp.media.view.l10n.audioDetailsText }}}</div>
</ins><span class="cx">                   <div class="embed-media-settings embed-audio-settings">
</span><span class="cx">                          <audio controls
</span><span class="cx">                                  class="wp-audio-shortcode"
</span><span class="lines">@@ -689,6 +690,7 @@
</span><span class="cx">                          <label class="setting">
</span><span class="cx">                                  <span>SRC</span>
</span><span class="cx">                                  <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" />
</span><ins>+                                       <a class="remove-setting">{{{ wp.media.view.l10n.audioRemoveSource }}}</a>
</ins><span class="cx">                           </label>
</span><span class="cx">                          <# } #>
</span><span class="cx">                          <?php
</span><span class="lines">@@ -698,6 +700,7 @@
</span><span class="cx">                          <label class="setting">
</span><span class="cx">                                  <span><?php echo strtoupper( $type ) ?></span>
</span><span class="cx">                                  <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" />
</span><ins>+                                       <a class="remove-setting">{{{ wp.media.view.l10n.audioRemoveSource }}}</a>
</ins><span class="cx">                           </label>
</span><span class="cx">                          <# } #>
</span><span class="cx">                          <?php endforeach ?>
</span><span class="lines">@@ -727,19 +730,22 @@
</span><span class="cx"> 
</span><span class="cx">  <script type="text/html" id="tmpl-video-details">
</span><span class="cx">          <?php $video_types = wp_get_video_extensions(); ?>
</span><del>-               <div class="media-embed">
</del><ins>+                <div class="media-embed media-embed-details">
+                       <div class="instructions media-instructions">{{{ wp.media.view.l10n.videoDetailsText }}}</div>
</ins><span class="cx">                   <div class="embed-media-settings embed-video-settings">
</span><span class="cx">                          <div class="wp-video-holder">
</span><span class="cx">                          <#
</span><del>-                               var w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width,
</del><ins>+                                var isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/);
+                                       w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width,
</ins><span class="cx">                                   h = ! data.model.height ? 360 : data.model.height;
</span><span class="cx"> 
</span><span class="cx">                          if ( data.model.width && w !== data.model.width ) {
</span><span class="cx">                                  h = Math.ceil( ( h * w ) / data.model.width );
</span><span class="cx">                          }
</span><ins>+
</ins><span class="cx">                           #>
</span><span class="cx">                          <video controls
</span><del>-                                       class="wp-video-shortcode youtube-video"
</del><ins>+                                        class="wp-video-shortcode{{ isYouTube ? ' youtube-video' : '' }}"
</ins><span class="cx">                                   width="{{ w }}"
</span><span class="cx">                                  height="{{ h }}"
</span><span class="cx">                                  <?php
</span><span class="lines">@@ -762,7 +768,7 @@
</span><span class="cx">                                  <?php endforeach ?>#>
</span><span class="cx">                          >
</span><span class="cx">                                  <# if ( ! _.isEmpty( data.model.src ) ) {
</span><del>-                                               if ( data.model.src.match(/youtube|youtu\.be/) ) { #>
</del><ins>+                                                if ( isYouTube ) { #>
</ins><span class="cx">                                           <source src="{{ data.model.src }}" type="video/youtube" />
</span><span class="cx">                                          <# } else { #>
</span><span class="cx">                                          <source src="{{ data.model.src }}" type="{{ wp.media.view.settings.embedMimes[ data.model.src.split('.').pop() ] }}" />
</span><span class="lines">@@ -779,6 +785,7 @@
</span><span class="cx">                          <label class="setting">
</span><span class="cx">                                  <span>SRC</span>
</span><span class="cx">                                  <input type="text" disabled="disabled" data-setting="src" value="{{ data.model.src }}" />
</span><ins>+                                       <a class="remove-setting">{{{ wp.media.view.l10n.videoRemoveSource }}}</a>
</ins><span class="cx">                           </label>
</span><span class="cx">                          <# } #>
</span><span class="cx">                          <?php foreach ( $video_types as $type ):
</span><span class="lines">@@ -786,14 +793,18 @@
</span><span class="cx">                          <label class="setting">
</span><span class="cx">                                  <span><?php echo strtoupper( $type ) ?></span>
</span><span class="cx">                                  <input type="text" disabled="disabled" data-setting="<?php echo $type ?>" value="{{ data.model.<?php echo $type ?> }}" />
</span><ins>+                                       <a class="remove-setting">{{{ wp.media.view.l10n.videoRemoveSource }}}</a>
</ins><span class="cx">                           </label>
</span><span class="cx">                          <# } #>
</span><span class="cx">                          <?php endforeach ?>
</span><span class="cx">                          </div>
</span><ins>+                               <# if ( ! _.isEmpty( data.model.poster ) ) { #>
</ins><span class="cx">                           <label class="setting">
</span><span class="cx">                                  <span><?php _e( 'Poster Image' ); ?></span>
</span><del>-                                       <input type="text" data-setting="poster" value="{{ data.model.poster }}" />
</del><ins>+                                        <input type="text" disabled="disabled" data-setting="poster" value="{{ data.model.poster }}" />
+                                       <a class="remove-setting">{{{ wp.media.view.l10n.videoRemovePoster }}}</a>
</ins><span class="cx">                           </label>
</span><ins>+                               <# } #>
</ins><span class="cx">                           <div class="setting preload">
</span><span class="cx">                                  <span><?php _e( 'Preload' ); ?></span>
</span><span class="cx">                                  <div class="button-group button-large" data-setting="preload">
</span></span></pre></div>
<a id="trunksrcwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/media.php (27477 => 27478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/media.php  2014-03-09 01:05:48 UTC (rev 27477)
+++ trunk/src/wp-includes/media.php     2014-03-09 05:24:10 UTC (rev 27478)
</span><span class="lines">@@ -2443,15 +2443,25 @@
</span><span class="cx">          'imageDetailsCancel'    => __( 'Cancel Edit' ),
</span><span class="cx">          'editImage'             => __( 'Edit Image' ),
</span><span class="cx"> 
</span><del>-               // Edit Image
</del><ins>+                // Edit Audio
</ins><span class="cx">           'audioDetailsTitle'     => __( 'Audio Details' ),
</span><span class="cx">          'audioReplaceTitle'     => __( 'Replace Audio' ),
</span><ins>+               'audioAddSourceTitle'   => __( 'Add Audio Source' ),
</ins><span class="cx">           'audioDetailsCancel'    => __( 'Cancel Edit' ),
</span><ins>+               'audioDetailsText'      => __( '"Replace Audio" will remove all associated source files when you update. ' .
+                       '"Add Audio Source" allows you to specify alternate sources for maximum native HTML5 audio playback.' ),
+               'audioRemoveSource'     => __( 'Remove Audio Source' ),
</ins><span class="cx"> 
</span><del>-               // Edit Image
</del><ins>+                // Edit Video
</ins><span class="cx">           'videoDetailsTitle'     => __( 'Video Details' ),
</span><span class="cx">          'videoReplaceTitle'     => __( 'Replace Video' ),
</span><ins>+               'videoAddSourceTitle'   => __( 'Add Video Source' ),
</ins><span class="cx">           'videoDetailsCancel'    => __( 'Cancel Edit' ),
</span><ins>+               'videoDetailsText'      => __( '"Replace Video" will remove all associated source files when you update. ' .
+                       '"Add Video Source" allows you to specify alternate sources for maximum native HTML5 video playback.' ),
+               'videoRemoveSource'     => __( 'Remove Video Source' ),
+               'videoSelectPosterImageTitle' => _( 'Select Poster Image' ),
+               'videoRemovePoster'     => __( 'Remove Poster Image' ),
</ins><span class="cx"> 
</span><span class="cx">                  // Playlist
</span><span class="cx">                  'playlistDragInfo'    => __( 'Drag and drop to reorder tracks.' ),
</span></span></pre>
</div>
</div>

</body>
</html>