Media: Add an audio and video player to the media manager modal.

This introduces a means of playing existing audio and video files while browsing them prior to selecting them for use.

Props antpb, Mista-Flo, garrett-eclipse, mapk

Fixes #43640

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


git-svn-id: http://core.svn.wordpress.org/trunk@48957 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2020-10-18 17:39:07 +00:00
parent 1faa241fb6
commit afbfe981fc
10 changed files with 69 additions and 25 deletions

View File

@ -1766,6 +1766,14 @@
padding-bottom: 11px;
}
.attachment-info .wp-media-wrapper {
margin-bottom: 8px;
}
.attachment-info .wp-media-wrapper.wp-audio {
margin-top: 13px;
}
.attachment-info .filename {
font-weight: 600;
color: #444;

File diff suppressed because one or more lines are too long

View File

@ -1765,6 +1765,14 @@
padding-bottom: 11px;
}
.attachment-info .wp-media-wrapper {
margin-bottom: 8px;
}
.attachment-info .wp-media-wrapper.wp-audio {
margin-top: 13px;
}
.attachment-info .filename {
font-weight: 600;
color: #444;

File diff suppressed because one or more lines are too long

View File

@ -491,17 +491,8 @@ TwoColumn = Details.extend(/** @lends wp.media.view.Attachment.Details.TowColumn
/**
* Noop this from parent class, doesn't apply here.
*/
toggleSelectionHandler: function() {},
toggleSelectionHandler: function() {}
render: function() {
Details.prototype.render.apply( this, arguments );
wp.media.mixin.removeAllPlayers();
this.$( 'audio, video' ).each( function (i, elem) {
var el = wp.media.view.MediaDetails.prepareSrc( elem );
new window.MediaElementPlayer( el, wp.media.mixin.mejsSettings );
} );
}
});
module.exports = TwoColumn;

File diff suppressed because one or more lines are too long

View File

@ -9194,6 +9194,7 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp
this.moveFocus();
}
},
/**
* Untrashes an attachment.
*
@ -9253,6 +9254,16 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp
this.controller.trigger( 'attachment:details:shift-tab', event );
return false;
}
},
render: function() {
Attachment.prototype.render.apply( this, arguments );
wp.media.mixin.removeAllPlayers();
this.$( 'audio, video' ).each( function (i, elem) {
var el = wp.media.view.MediaDetails.prepareSrc( elem );
new window.MediaElementPlayer( el, wp.media.mixin.mejsSettings );
} );
}
});

File diff suppressed because one or more lines are too long

View File

@ -366,7 +366,7 @@ function wp_print_media_templates() {
<# } #>
<# if ( 'audio' === data.type ) { #>
<div class="wp-media-wrapper">
<div class="wp-media-wrapper wp-audio">
<audio style="visibility: hidden" controls class="wp-audio-shortcode" width="100%" preload="none">
<source type="{{ data.mime }}" src="{{ data.url }}"/>
</audio>
@ -595,15 +595,41 @@ function wp_print_media_templates() {
</span>
</h2>
<div class="attachment-info">
<div class="thumbnail thumbnail-{{ data.type }}">
<# if ( data.uploading ) { #>
<div class="media-progress-bar"><div></div></div>
<# } else if ( 'image' === data.type && data.size && data.size.url ) { #>
<img src="{{ data.size.url }}" draggable="false" alt="" />
<# } else { #>
<img src="{{ data.icon }}" class="icon" draggable="false" alt="" />
<# } #>
</div>
<# if ( 'audio' === data.type ) { #>
<div class="wp-media-wrapper wp-audio">
<audio style="visibility: hidden" controls class="wp-audio-shortcode" width="100%" preload="none">
<source type="{{ data.mime }}" src="{{ data.url }}"/>
</audio>
</div>
<# } else if ( 'video' === data.type ) {
var w_rule = '';
if ( data.width ) {
w_rule = 'width: ' + data.width + 'px;';
} else if ( wp.media.view.settings.contentWidth ) {
w_rule = 'width: ' + wp.media.view.settings.contentWidth + 'px;';
}
#>
<div style="{{ w_rule }}" class="wp-media-wrapper wp-video">
<video controls="controls" class="wp-video-shortcode" preload="metadata"
<# if ( data.width ) { #>width="{{ data.width }}"<# } #>
<# if ( data.height ) { #>height="{{ data.height }}"<# } #>
<# if ( data.image && data.image.src !== data.icon ) { #>poster="{{ data.image.src }}"<# } #>>
<source type="{{ data.mime }}" src="{{ data.url }}"/>
</video>
</div>
<# } else { #>
<div class="thumbnail thumbnail-{{ data.type }}">
<# if ( data.uploading ) { #>
<div class="media-progress-bar"><div></div></div>
<# } else if ( 'image' === data.type && data.size && data.size.url ) { #>
<img src="{{ data.size.url }}" draggable="false" alt="" />
<# } else { #>
<img src="{{ data.icon }}" class="icon" draggable="false" alt="" />
<# } #>
</div>
<# } #>
<div class="details">
<div class="filename">{{ data.filename }}</div>
<div class="uploaded">{{ data.dateFormatted }}</div>

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6-alpha-49194';
$wp_version = '5.6-alpha-49195';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.