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

Background Media support: relevant Video updates + basic implementation #194

Merged
merged 39 commits into from
Feb 5, 2020

Conversation

miina
Copy link
Contributor

@miina miina commented Feb 3, 2020

Partial for #25:

  • Adds Set/Remove as background button + related functionality/style
  • Adds edit mode for video
  • Adds panning for video
  • First media element on a page is added as background

Todo:

@miina
Copy link
Contributor Author

miina commented Feb 3, 2020

@dvoytenko @spacedmonkey @swissspidy This is partial for #25 -- since the video edit mode wasn't implemented previously but panning is necessary for the background media, then this PR currently implements basic background setting (button + when adding media to an empty page) and the required parts for video element.

Thinking that perhaps we could get these merged and then address the remaining issues (listed out in the description) separately to avoid the PR getting too huge. Thoughts?

assets/src/edit-story/components/canvas/displayLayer.js Outdated Show resolved Hide resolved
assets/src/edit-story/components/library/libraryContent.js Outdated Show resolved Hide resolved
assets/src/edit-story/components/panels/background.js Outdated Show resolved Hide resolved
assets/src/edit-story/elements/shared/index.js Outdated Show resolved Hide resolved
assets/src/edit-story/elements/video/display.js Outdated Show resolved Hide resolved
assets/src/edit-story/elements/video/edit.js Show resolved Hide resolved
assets/src/edit-story/elements/video/scalePanel.js Outdated Show resolved Hide resolved
@@ -43,9 +43,16 @@
<noscript><style amp-boilerplate="">body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<?php /* todo: include custom CSS via PHP */ ?>
<style amp-custom>
.full-bleed > :first-child {
.is-fill > :first-child {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not for this PR, but I'm curious, why shouldn't we generate the <style amp-custom> (or even the rest of this document) entirely in our JS code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, this template is using WordPress filters and functions to use and display relevant data from the site. Also, previously the amp-custom was put together automatically after tree-shaking, combining all the relevant styles. Not knowing if this will be the case in the future as well, amp-custom was just added as a quick replacement when separating the Stories plugin from AMP. Basically -- this part has just never been seriously discussed in terms of how to store/generate, it might be good to do that before the first release.

For portability, it would be more convenient for example, if the amp-story tag would also be saved together with the content, currently, only the pages inside amp-story are saved.

Copy link
Contributor

Choose a reason for hiding this comment

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

Filed #233.

@@ -35,10 +35,24 @@ function VideoPreview( { id, mimeType, src, width, height, x, y, rotationAngle,
id: 'el-' + id,
};

const style = getCommonAttributes( { width, height, x, y, rotationAngle } );
const style = isBackground ?
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic is repeated.

Copy link
Contributor

@dvoytenko dvoytenko left a comment

Choose a reason for hiding this comment

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

LG with one comment re: resetting isBackground: true somewhere. PTAL.

@miina miina marked this pull request as ready for review February 5, 2020 08:35
} :
getCommonAttributes( { width, height, x, y, rotationAngle } );

if ( isBackground ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we respect the existing autoPlay param passed to this component? Maybe change that instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, not sure. I suppose that's a UX question. It seems like if a video is set as background then it should always autoplay, however, when the background is unset again for that element then I'd assume that the previous autoplay setting would remain as it was before.

Let's confirm with UX, this could also be addressed in #45 once the UX for the Video element is confirmed.

Copy link
Contributor

Choose a reason for hiding this comment

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

For some reason I was always under the impression that all videos always autoplay in stories. I'm looking at the doc here, which states:

Note that amp-video extension has different validation rules when used within an AMP Story—both the autoplay and poster attributes are required.

And consequently, I don't think controls are allowed or make much sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I think we've had that conversation before with the previous Stories editor as well already.

Yep, here's a relevant PR:
ampproject/amp-wp#2255

So yes, it looks like the controls don't really make sense anyway. Will leave this for resolving/looking into in #45 and related issues and merge as-is for the background media.

@miina miina merged commit cbfa43f into master Feb 5, 2020
@miina miina deleted the add/25-background-media-support branch February 5, 2020 19:41
Copy link
Contributor

@spacedmonkey spacedmonkey left a comment

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants