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

VideoPress: add RN mobile video player block #29165

Closed
wants to merge 77 commits into from

Conversation

jhnstn
Copy link
Member

@jhnstn jhnstn commented Feb 24, 2023

Fixes wordpress-mobile/gutenberg-mobile#5509

Proposed changes:

  • Add a native supported VideoPress video player block

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

TBD

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2023

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ⚠️ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: March 7, 2023.
  • Scheduled code freeze: February 28, 2023.

Backup plugin:

  • Next scheduled release: March 7, 2023.
  • Scheduled code freeze: February 28, 2023.

Boost plugin:

  • Next scheduled release: April 4, 2023.
  • Scheduled code freeze: March 27, 2023.

Social plugin:

  • Next scheduled release: March 7, 2023.
  • Scheduled code freeze: February 28, 2023.

Starter Plugin plugin:

  • Next scheduled release: April 4, 2023.
  • Scheduled code freeze: March 27, 2023.

Protect plugin:

  • Next scheduled release: April 4, 2023.
  • Scheduled code freeze: March 27, 2023.

Videopress plugin:

  • Next scheduled release: April 4, 2023.
  • Scheduled code freeze: March 27, 2023.

Super Cache plugin:

  • Next scheduled release: April 4, 2023.
  • Scheduled code freeze: March 27, 2023.

Migration plugin:

  • Next scheduled release: April 4, 2023.
  • Scheduled code freeze: March 27, 2023.

Crm plugin:

  • Next scheduled release: April 4, 2023.
  • Scheduled code freeze: March 27, 2023.

Mu Wpcom plugin plugin:

  • Next scheduled release: April 4, 2023.
  • Scheduled code freeze: March 27, 2023.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2023

Are you an Automattician? You can now test your Pull Request on WordPress.com. On your sandbox, run

bin/jetpack-downloader test jetpack rnmobile/update-vp-player
bin/jetpack-downloader test jetpack-mu-wpcom-plugin rnmobile/update-vp-player

to get started. More details: p9dueE-5Nn-p2

retrofox and others added 5 commits February 27, 2023 06:58
* [not verified] first approach of the poster panel

* [not verified] export poster media types constant

* [not verified] tweak poster image help section

* [not verified] set background image to panel button

* [not verified] add poster panel to the default settings tab

* [not verified] changelog

* Update projects/packages/videopress/src/client/block-editor/blocks/video/components/poster-panel/style.scss

Co-authored-by: Douglas Henri <dhasilva@users.noreply.github.com>

* [not verified] move poster action label to a const

* two const > one const :smart:

---------

Co-authored-by: Douglas Henri <dhasilva@users.noreply.github.com>
Co-authored-by: Douglas <douglas.henri@automattic.com>
* [not verified] use tertiary and destructive style for remove btn

* [not verified] do not use CSS module

* [not verified] tweak delete button layout

* changelog
…29173)

* [not verified] use a const to define image styles dynamically

* [not verified] adjust poster image height based on video ratio

* changelog
* Exclude deferred JS in customizer preview

* changelog

---------

Co-authored-by: Mark George <thingalon@gmail.com>
…ement (#28403)

Co-authored-by: Matt Gawarecki <matt.gawarecki@automattic.com>
// Pick video properties from preview.
const { html: previewHtml, scripts } = preview;

const html = previewHtml || cacheHtml;
Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding cacheHtml attribute, we'd need to replicate the same logic we have in the web version (reference).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure this is entirely true.

I did see the effect that sets the cacheHtml attribute in the web version, which you referenced, but I don't see where the attribute is actually being used in the video player component. For now I would suggest we keep the current logic scoped to what is needed to render the video player.

That said I find the comments above the effect hook puzzling and makes wonder if the cacheHtml attribute is actually needed. The comment mentions setting html and thumbnail attributes, neither of which are actually set in the effect hook.
I'll do some commit spelunking to find the reasoning for the setting the cacheHtml attribute, perhaps it is needed for the some of the other components like <VideoPressUploader> or <PlaceholderWrapper>

Copy link
Contributor

Choose a reason for hiding this comment

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

I did see the effect that sets the cacheHtml attribute in the web version, which you referenced, but I don't see where the attribute is actually being used in the video player component. For now I would suggest we keep the current logic scoped to what is needed to render the video player.

I think the purpose of the cacheHtml attribute is to be used upon the component being mounted to display the video player while the preview is being fetched, as it's mentioned in this comment:

* `html` will be used to render the player asap,
* while a fresh preview is going fetched from the server,
* via the core store selectors.

I understand that this is an enhancement to avoid displaying a loading indicator, which we might consider implementing in the native version. In any case, I tested this functionality in the web version and it's true that is hard to tell the difference with and without having the cache, especially as the HTML content is an iframe that still needs to load the video player content 🤔.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the purpose of the cacheHtml attribute is to be used upon the component being mounted to display the video player while the preview is being fetched

Seems like the const html = previewHtml || cacheHtml assignment covers the mounting period in the block lifecycle.

This enhancement might be for when the preview is fetched after the component is mounted. The hook logic suggests that the previewHtml would have to exist then not exist before the setAttribute call would have any relevance.

I'm guessing that happens when the video source is updated. If so, we should probably handle that when we get to settings or uploading updates.

return (
<View
style={ { height: videoPlayerHeight } }
onLayout={ ( { nativeEvent } ) => scaleVideoPlayer( nativeEvent ) }
Copy link
Contributor

Choose a reason for hiding this comment

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

I recall that the height was automatically set in the Sandbox component (reference) communicating with the embed content, not sure if we could apply a similar approach for the VideoPress player 🤔 .

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe I was running into issues with the aspect ratio of the videos, not just the height. I'll play around with this to see if I can get the Sandbox to handle it correctly

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok I figured out what's going on here. I was following the web version a bit too closely I think. There is a "loading" view that needs some height. I think the web version also needs to handle responsive UI changes so I'm assuming the height needs to be handled explicitly.

I can handle the "is loading" state better which simplifies a lot of things.
Thanks for pointing that out!

preview,
isRequestingEmbedPreview,
} ) {
const [ videoPlayerHeight, setVideoPlayerHeight ] = useState( 250 );
Copy link
Contributor

Choose a reason for hiding this comment

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

In the web version, a temporary height is set, maybe we could replicate a similar logic instead of having a constant, WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you referencing the magic number 250 ? That's just a replacement for the temporary styling height that was added here. I would expect that to be modified later once we get into refining the component. That said the web version also uses a constant, just not in the useState call. ( Just noticed while writing this that the web version now uses a constant as well )

Or are you talking the web version use of state.videoPlayerTemporaryHeight . It's really just naming. I've simplified the logic involved in calling setVideoPlayerHeight vs the web version setVideoPlayerTemporaryHeight but the intent is the same. I expect the calling logic to become more complex in future changes so I opted to keep it simple for now.
I found the use of temporary misleading in the web version. I couldn't find a condition where the "temporary" height is not used, it is ignored once the embed is rendered but it's not replaced or removed. Perhaps a better name, in both cases, is playerWrapperHeight since that is where how the state property is used.

Copy link
Contributor

@fluiddot fluiddot Mar 6, 2023

Choose a reason for hiding this comment

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

Are you referencing the magic number 250 ? That's just a replacement for the temporary styling height that was added here. I would expect that to be modified later once we get into refining the component. That said the web version also uses a constant, just not in the useState call. ( Just noticed while writing this that the web version now uses a constant as well )

Yeah, I was referencing the magic number. Oh, true, in the web version we also have a constant. In that case, omit my comment then, thanks for elaborating!

Or are you talking the web version use of state.videoPlayerTemporaryHeight . It's really just naming. I've simplified the logic involved in calling setVideoPlayerHeight vs the web version setVideoPlayerTemporaryHeight but the intent is the same. I expect the calling logic to become more complex in future changes so I opted to keep it simple for now.
I found the use of temporary misleading in the web version. I couldn't find a condition where the "temporary" height is not used, it is ignored once the embed is rendered but it's not replaced or removed. Perhaps a better name, in both cases, is playerWrapperHeight since that is where how the state property is used.

Based on the following comment, I understand that the temporary height is just an initial calculation we make based on the block's width and the video's aspect ratio. Once the player is loaded, the height is replaced with the final value, so it seems the temporariness is based on the fact that is only used during the loading state.

/*
* Temporary height is used to set the height of the video
* as soon as the block is rendered into the canvas
* while the preview fetching process is happening,
* trying to reduce the flicker effects as much as possible.
* Once the preview is fetched, the temporary height is ignored.
*/

Copy link
Member Author

@jhnstn jhnstn Mar 6, 2023

Choose a reason for hiding this comment

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

It's true that there is an initial value for the height that is derived from the aspect ratio.
The issue I see is the naming. From what I observed the videoPlayerTemporaryHeight state variable is always used to set the style height property.

In fact once the video is available, videoPlayerTemporaryHeight is set to auto here

In other words, this state variable has an initial value to set a placeholder height, and then is set to auto once the actual height is available. To me that variable is not temporary. If I see something named temporary with a comment that it's eventually ignored, I would expect to see it used like

const value = actualValue || temporaryValue

instead the code here is more like

let temporaryValue = 1;
eventually( (actualValue) => setTemporaryValue(actualValue) )
const value = temporaryValue

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact once the video is available, videoPlayerTemporaryHeight is set to auto here

In other words, this state variable has an initial value to set a placeholder height, and then is set to auto once the actual height is available. To me that variable is not temporary. If I see something named temporary with a comment that it's eventually ignored, I would expect to see it used like

Yep, good point. I agree the videoPlayerTemporaryHeight is a bit confusing, especially when the auto value is set because is not consistent with the temporariness led by the variable name. I understand that the purpose of auto is basically disabling the temporary height and letting the video player control the height, maybe the value should be renamed to disabled or something similar 🤔. For the native version, if we have to provide a customized version of the component, we can discuss further how to name and structure this part if needed.

anomiex and others added 15 commits February 27, 2023 10:37
* cli: `generate` command should ask for plugin versioning method

We've been defaulting to semver like we do for all other project types,
but it seems this may be confusing teams working on the plugins who may
be expecting WordPress-style versioning. Instead let's ask when the
plugin is being created.
Co-authored-by: Jeremy Herve <jeremy@jeremy.hu>
* Add a pricing-utils helper folder

This folder will store helper functions related to pricing. For now, I've only included `isFirstMonthTrial` as it's the only one required for this PR, but intention is to add more functions related to pricing, instead of having them only as reducers/selectors.

* Recommendations: remove discount if there's a trial

* Recommendations: remove the coupon code from the URL if there's a trial

This change is made in the component instead of in withUpgradeUrl because this rule is more strict and related specifically to what is displayed in this card. This change is mostly to avoid visual confusion.

* Add changelogger

* Remove unnecessary CSS

* Fix changelogger validity
…us (#28820)

* Increase form fields padding based on user-defined border-radius

* changelog

* Fix field padding in the Forms package

* changelog

* Fix changelogger
* Odyssey: Remove Calypso nudge.

Doesn’t make sense to push to Calypso now that Odyssey is an option.

* Odyssey: Remove Calypso nudge (2).

This time from the loading UI.

* Changelog++
* [not verified] Add block support for font family in Related Posts block server block renderer

* [not verified] changelog
…ideo (#29183)

* remove image for poster when uploading video

* fix default aspect ratio

* changelog
* Jetpack: update to-test.md for v11.9

* Typos and formatting
…#29198)

* Update the forms dashboard to use the same feedback menu item

* changelog
@github-actions github-actions bot added [Package] Search Contains core Search functionality for Jetpack and Search plugins [Package] Stats Admin [Package] WAF [Package] WP JS Data Sync [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] CRM Issues about the Jetpack CRM plugin [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Migration [Plugin] Mu Wpcom Plugin [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Starter Plugin [Plugin] Super Cache A fast caching plugin for WordPress. [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Status] Needs Test Review [Tools] Development CLI The tools/cli to assist during JP development. Actions GitHub actions used to automate some of the work around releases and repository management Admin Page React-powered dashboard under the Jetpack menu [Feature] Contact Form E2E Tests [Feature] Masterbar WordPress.com Toolbar and Dashboard customizations [Feature] Related Posts RNA [Feature] Sharing Post sharing, sharing buttons [Feature] Widget Visibility [Feature] WPCOM API labels Mar 3, 2023
@jhnstn jhnstn deleted the rnmobile/update-vp-player branch March 3, 2023 17:49
@jeherve jeherve added the [Plugin] mu wpcom jetpack-mu-wpcom plugin label Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Action] Repo Gardening Github Action: manage PR and issues in your Open Source project Actions GitHub actions used to automate some of the work around releases and repository management Admin Page React-powered dashboard under the Jetpack menu [Block] Anchor Fm Anchor.fm integration [Block] Blogging Prompt [Block] Contact Form Form block (also see Contact Form label) [Block] Conversation [Block] Cookie Consent [Block] Dialogue [Block] GIF [Boost Feature] Image Guide [Boost Feature] Optimizations E2E Tests [Extension] Launchpad Save Modal [Feature] Contact Form [Feature] Masterbar WordPress.com Toolbar and Dashboard customizations [Feature] Related Posts [Feature] Sharing Post sharing, sharing buttons [Feature] Widget Visibility [Feature] WPCOM API [JS Package] API [JS Package] Base Styles [JS Package] Components [JS Package] Connection [JS Package] Eslint Config Target Es [JS Package] I18n Loader Webpack Plugin [JS Package] IDC [JS Package] Licensing [JS Package] Partner Coupon [JS Package] Publicize Components [JS Package] Shared Extension Utils [JS Package] Storybook [JS Package] Svelte Data Sync Client [JS Package] Webpack Config [Package] Action Bar This package no longer exists in the monorepo. [Package] Ad aka WordAds [Package] Assets [Package] Backup [Package] Blaze [Package] Connection [Package] Forms [Package] Identity Crisis This package no longer exists in the monorepo. It was merged into [Package] Connection. [Package] IP [Package] Jetpack mu wpcom WordPress.com Features [Package] Jitm [Package] Lazy Images This package no longer exists in the monorepo. [Package] My Jetpack [Package] Publicize [Package] Search Contains core Search functionality for Jetpack and Search plugins [Package] Stats Admin [Package] VideoPress [Package] WAF [Package] WP JS Data Sync [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] CRM Issues about the Jetpack CRM plugin [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Migration [Plugin] mu wpcom jetpack-mu-wpcom plugin [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Starter Plugin [Plugin] Super Cache A fast caching plugin for WordPress. [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. RNA [Status] Needs Test Review [Tools] Development CLI The tools/cli to assist during JP development.
Projects
None yet
Development

Successfully merging this pull request may close these issues.