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

Video Editor: Add VideoPress poster picker #11653

Merged
merged 30 commits into from
Jun 16, 2017
Merged

Conversation

donnapep
Copy link
Contributor

@donnapep donnapep commented Feb 28, 2017

This PR enables choosing a custom VideoPress poster by either selecting a particular frame of the video or by uploading a custom image.

Testing

Test using a site that has VideoPress enabled (e.g. a WP.com site that has a Premium plan or a Jetpack site that has a Jetpack Premium plan and VideoPress enabled in Jetpack settings).

The Video Editor can be accessed in the post editor by selecting "Add Media" from the toolbar dropdown, selecting a video, clicking the "Edit" button, and then clicking the "Edit Thumbnail" button.

It can also be accessed by clicking "Media" in the sidebar, selecting a video, clicking the "Edit" button, and then clicking the "Edit Thumbnail" button:

screen shot 2017-02-15 at 11 42 15 am

screen shot 2017-02-15 at 11 37 29 am

If the video cannot be loaded or an error occurs when updating the poster, the following message is shown:

screen shot 2017-02-15 at 11 38 09 am

@donnapep donnapep self-assigned this Feb 28, 2017
@matticbot
Copy link
Contributor

@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Feb 28, 2017
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 6, 2017
let editText = translate( 'Edit Image' );

if ( 'video' === mimePrefix ) {
editText = translate( 'Edit Thumbnail' );
Copy link

Choose a reason for hiding this comment

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

Hi! I've found a possible matching string that has already been translated 79 times:
translate( 'Thumbnail' ) ES Score: 7

Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).

@donnapep donnapep force-pushed the add/videopress-poster-picker branch from b41e9d7 to 10a02e5 Compare March 6, 2017 13:32
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 6, 2017
@donnapep donnapep force-pushed the add/videopress-poster-picker branch from f2caf7e to 9b494b4 Compare March 6, 2017 13:40
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 6, 2017
@donnapep donnapep force-pushed the add/videopress-poster-picker branch from 596251e to 275a137 Compare March 14, 2017 12:01
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 14, 2017
@donnapep donnapep force-pushed the add/videopress-poster-picker branch from 275a137 to 5ccf071 Compare March 14, 2017 12:04
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 14, 2017
@donnapep donnapep force-pushed the add/videopress-poster-picker branch from 7f53819 to 57d607f Compare March 14, 2017 13:11
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 14, 2017
@donnapep donnapep force-pushed the add/videopress-poster-picker branch from a273540 to f14a88f Compare March 14, 2017 13:34
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 14, 2017
@donnapep donnapep force-pushed the add/videopress-poster-picker branch from a33e749 to 599bd53 Compare March 14, 2017 13:38
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 14, 2017
@donnapep donnapep force-pushed the add/videopress-poster-picker branch from c802025 to 72f6b28 Compare March 14, 2017 13:46
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 14, 2017
@donnapep donnapep force-pushed the add/videopress-poster-picker branch from a2bd5c6 to e32ab0e Compare March 14, 2017 14:51
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 14, 2017
@@ -36,6 +37,7 @@ class EditorMediaModalDetailPreviewVideoPress extends Component {

componentDidMount() {
this.loadInitializeScript();
window.addEventListener( 'message', this.receiveMessage, false );
Copy link
Member

Choose a reason for hiding this comment

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

is there a reason this isn't unloaded in componentWillUnmount?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's being removed in the destroy function, which is called by componentWillUnmount. destroy is also called in componentDidUpdate, since if the VideoPress ID changes, the player needs to be re-initialized.

receiveMessage = ( event ) => {
if ( event.origin && event.origin !== location.origin ) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

very good!


const data = 'string' === typeof event.data
? JSON.parse( event.data )
: event.data;
Copy link
Member

Choose a reason for hiding this comment

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

was it with @gwwar that I recently held a discussion on this? there's something about this construction I don't like (also it's unsafe because JSON.parse() throws on invalid syntax) because it assumes that string data is JSON data

I would be far more in favor of something else like this…

const parseEventData = data => {
	try {
		return JSON.parse( data );
	} catch (e) {
		return data;
	}
}



const data = parseEventData( event.data );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, the response is already JSON. I have no idea why I was trying to parse it. 🤦‍♀️

Copy link
Member

Choose a reason for hiding this comment

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

if we want to use JSON data we will need to parse it, otherwise it's just a string…

Copy link
Contributor Author

@donnapep donnapep Mar 21, 2017

Choose a reason for hiding this comment

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

Huh? Not sure I follow, since event.data is already an object. I discovered parsing wasn't necessary by actually trying to parse it and then realizing the catch handler fired every time.

I was like, 'Calypso, JSON.parse( event.data )!', and Calypso was all like Unexpected token o in JSON at position 1! So buh bye JSON.parse!

@donnapep donnapep force-pushed the add/videopress-poster-picker branch 2 times, most recently from 06ad32d to b17aae4 Compare March 22, 2017 18:19
@donnapep donnapep force-pushed the add/videopress-poster-picker branch from c5d2b14 to 0924df1 Compare June 16, 2017 10:19
@donnapep
Copy link
Contributor Author

@ockham Awesome! Tested everything again and it's all still working so I'm going to go ahead and deploy. Thx! 😃

@donnapep donnapep merged commit f68d71a into master Jun 16, 2017
@donnapep donnapep deleted the add/videopress-poster-picker branch June 16, 2017 10:30
@kraftbj
Copy link
Contributor

kraftbj commented Aug 14, 2017

We noticed that this is live for staging, but still disabled in production ( https://github.com/Automattic/wp-calypso/blob/master/config/stage.json#L82 vs https://github.com/Automattic/wp-calypso/blob/master/config/production.json#L77 ). Is there a timeline for rolling it out to prod?

634025-zen

@chaselivingston
Copy link

Also requested in production here: 624739-zen

@donnapep
Copy link
Contributor Author

@kraftbj @chaselivingston I'll get a PR together to deploy to production. Cheers.

@donnapep
Copy link
Contributor Author

PR is here and is awaiting review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Size] XL Probably needs to be broken down into multiple smaller issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants