Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable playing the Core Video block's video in the editor #2799

Merged
merged 11 commits into from
Jul 15, 2019

Conversation

kienstra
Copy link
Contributor

@kienstra kienstra commented Jul 12, 2019

  • Allows the video in the Core Video block to play in the editor
  • This forks the Core Video block's edit component
  • Ideally, this would just extend that component, and override the render() method.
  • But that caused a console warning, that suggested that the class extend Component instead of the Video BlockEdit
  • Also incorporates logic to automatically set the poster image upon video selection
  • Also prevents the poster warning to be shown in edit mode by inlining the withVideoPosterImageNotice logic within the component itself.
  • Prevents poster image to be removed as it is required. It can only be replaced.

Closes #2530.
Fixes #2808.

Ideally, this would just extend that component,
and override the render() method.
But that caused a console warning.
@googlebot googlebot added the cla: yes Signed the Google CLA label Jul 12, 2019
// Set the block's src from the edit component's state, and switch off
// the editing UI.
if ( newSrc !== src ) {
// Omit the embed block logic, as that didn't seem to work.
Copy link
Contributor Author

@kienstra kienstra Jul 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before, entering an embed URL below 'Insert from URL' was supposed to create an Embed block:

insert-from-url

This is intentionally disabled for YouTube, but even other embeds like Vimeo don't seem to display.

Is it OK that I removed the logic to convert to embeds?

https://github.com/WordPress/gutenberg/blob/cb718ffdff57e35f05f4239ff03ceb476ae69a86/packages/block-library/src/video/edit.js#L111-L117

Entering a non-embed URL still works. But embed support will probably require copying a lot of other dependencies, like createUpgradedEmbedBlock(), making this file much longer.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK that I removed the logic to convert to embeds?

I suppose so. AMP Stories doesn't really support any external providers AFAIK.

cc @westonruter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AMP Story should support Twitter embed in theory.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pasting a tweet URL in a video block and converting it to a twitter embed would be a bit unexpected, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True 😄 My comment was a bit out of context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

External video providers aren't supported yet, but support is planned soon: ampproject/amphtml#15847

The Video block has a display that shows
only the video, and one that allows editing.
Before, I thought of letting the original
block handle the display for editing.
But it looks like that's not possible.
This will probably be important to allow
another PR to filter the mediaUpload
to only allow certain types.
@kienstra
Copy link
Contributor Author

kienstra commented Jul 12, 2019

Request For Review
Hi @swissspidy and @miina,
Could you please review this?

It allows the video in the Core Video block to play in the editor, where it was wrapped in <Disabled> before:

video-autoplay

Though this might be overkill, as it forks most of the Core Vide block's edit component.

I couldn't figure out a way around this. I tried creating a new class that extends the Video edit component, like:

class VideoEditWithPreview extends InitialBlockEdit {
        render() {
               /* implements render */
        }
}

Ideally, this would simply override the render() method, and inherit the rest of the parent class's methods.

This caused a console warning that the component should instead extend Component.

Maybe there's another way around this that I haven't thought of.

Thanks, and have a great weekend!

@kienstra kienstra requested review from miina and swissspidy July 12, 2019 03:13
<InspectorControls>
<PanelBody title={ __( 'Video Settings' ) }>
<ToggleControl
label={ __( 'Playback Controls' ) }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhm, it doesn't seem like controls are actually displayed in AMP Stories? The runtime seems to hide them no matter what.

@westonruter Can you confirm this? Should we just remove this option?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK this was already removed at some point.

Found also this: #2255 where controls was set to false by default.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm so we should remove the controls setting, but keep the loop (default to true) and mute settings?

Even though mute doesn't seem to have any effect. When opening an AMP Story, sound is muted by default for the whole story (see upper right corner), and when I enable sound, the video is not muted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the mute control doesn't seem to have any effect anyway, looks like "Loop" is the only control that actually does anything.

Seems like we could probably just add the loop and leave the rest out for now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added back the loop setting and removed the one for controls.

If loop is disabled, controls are still shown since one might want to re-start the video during editing.

@swissspidy swissspidy requested a review from westonruter July 13, 2019 13:28
@swissspidy swissspidy added this to the v1.2.1 milestone Jul 13, 2019
Copy link
Collaborator

@swissspidy swissspidy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1-2 open questions but otherwise works great.

@swissspidy
Copy link
Collaborator

As pointed out in #2808, I think we can now easily move the logic from withVideoPosterImageNotice into our custom block edit component. This would allow fixing #2808 and simplify the code there.

Video poster images are required. Clicking on the remove button doesn’t work anyway as the stories editor automatically assigns the poster image again.
@swissspidy swissspidy self-requested a review July 15, 2019 13:22
@kienstra
Copy link
Contributor Author

As pointed out in #2808, I think we can now easily move the logic from withVideoPosterImageNotice into our custom block edit component. This would allow fixing #2808 and simplify the code there.

Ah, good point.

@swissspidy
Copy link
Collaborator

Since I added some changes, I'd like another pair of eyes do the final review here 🙂

@kienstra
Copy link
Contributor Author

@swissspidy, would it help if I reviewed the latest changes?

@swissspidy
Copy link
Collaborator

@kienstra Sure, but you cannot approve your own PR :-)

@swissspidy swissspidy merged commit e63d2c3 into develop Jul 15, 2019
@swissspidy swissspidy deleted the add/video-previews-editor branch July 15, 2019 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Signed the Google CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Video poster image warning shown in placeholder Enable video previews in editor
5 participants