Skip to content

[Gutenberg]Video insert & upload#11454

Merged
marecar3 merged 26 commits intodevelopfrom
gutenberg/video-upload
May 12, 2019
Merged

[Gutenberg]Video insert & upload#11454
marecar3 merged 26 commits intodevelopfrom
gutenberg/video-upload

Conversation

@pinarol
Copy link
Copy Markdown
Contributor

@pinarol pinarol commented Apr 11, 2019

Fixes wordpress-mobile/gutenberg-mobile#855

There are also some more TODO items in this issue: wordpress-mobile/gutenberg-mobile#687 (comment) which are not handled in this PR

gutenberg-mobile PR: wordpress-mobile/gutenberg-mobile#854

To test:

Prerequisites:
Run metro on gutenberg-mobile PR branch
Run rake dependencies

Test 1

First of all try all the media upload test cases described here:wordpress-mobile/gutenberg-mobile#854 (Except, in order to fail the upload try turning off the internet and waiting a bit)

Test 2

Try uploading by video capture by selecting Take a Video in a real device:
Screen Shot 2019-04-15 at 19 22 56

Test 3 Media filters

Media is filtered due to the block type with this PR
So you should be able to pick/capture only videos for video block, and only images for image block
Check both blocks and verify that this is true for all the options here:
Screen Shot 2019-04-15 at 19 22 56

Test 4 Add caption

Add a video caption text and save the post
Reopen the same post and verify the caption is added

Test 5 Simultaneous uploads

Try adding multiple video and image blocks
And try simultaneous uploads
Verify that there's no confusion and every upload is completed successfully to their intended block

Test 6 Switch to Classic editor

Add a video block and add video in it
Switch to Classic editor
Verify that video is there and it is playable

Update release notes:

  • If there are user facing changes, I have added an item to RELEASE-NOTES.txt.
    We aren't shipping the video block to production yet

@pinarol pinarol force-pushed the gutenberg/video-upload branch from 6594f42 to 97b51f5 Compare April 11, 2019 11:59
@pinarol
Copy link
Copy Markdown
Contributor Author

pinarol commented Apr 17, 2019

We can experiment on running tests in the test plan I prepared for video block https://wordpress-mobile.testquality.com/project/6587/plan/11476/run/91298

@pinarol pinarol requested a review from SergioEstevao April 17, 2019 13:11
@pinarol
Copy link
Copy Markdown
Contributor Author

pinarol commented Apr 17, 2019

cc @koke

# Conflicts:
#	Podfile
#	Podfile.lock
Copy link
Copy Markdown
Contributor

@SergioEstevao SergioEstevao left a comment

Choose a reason for hiding this comment

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

I tested the iOS app, and things are working great. I tested the following:

  • Add a video from device
  • Add a video from media library
  • Cancel a video upload by tapping the image
  • Cancel a video upload by deleting the block
  • Retested the image functionality.

break
}
gutenberg.mediaUploadUpdate(id: mediaUploadID, state: .succeeded, progress: 1, url: url, serverID: mediaServerID)
if media.mediaType == .image {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe a switch will be better, just in case in the future we add some extra cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

}
}

func fetchVideoPressUrl(for media: Media, completion: @escaping ( Result<(videoURL: URL, posterURL: URL?)> ) -> Void) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the name should be fetchVideoPressURL

Copy link
Copy Markdown
Contributor Author

@pinarol pinarol Apr 24, 2019

Choose a reason for hiding this comment

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

that method's implementation has changed so I updated its name as fetchRemoteURL

if media.mediaType == .image {
gutenberg.mediaUploadUpdate(id: mediaUploadID, state: .succeeded, progress: 1, url: url, serverID: mediaServerID)
} else if media.mediaType == .video {
fetchVideoPressUrl(for: media) { [weak self] (result) in
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

VideoPress information will only be available if the site is WordPress.com or using Jetpack.
If it's a self-hosted site without Jetpack the video will not be videoPress and you will need to send the 'media.remoteURL' directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

great catch! I have updated the code accordingly


func fetchVideoPressUrl(for media: Media, completion: @escaping ( Result<(videoURL: URL, posterURL: URL?)> ) -> Void) {
guard let videoPressID = media.videopressGUID else {
completion(Result.error(NSError()))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If there is no videoPressID the site can be a self-hosted site without VideoPress so you should return directly the media.remoteURL

Copy link
Copy Markdown
Contributor Author

@pinarol pinarol Apr 24, 2019

Choose a reason for hiding this comment

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

Great insights @SergioEstevao ! Luckily I have a self-hosted site which I only use for testing, I had the chance to test on that and yes media.remoteURL works like a charm

Copy link
Copy Markdown
Contributor Author

@pinarol pinarol Apr 24, 2019

Choose a reason for hiding this comment

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

cc @marecar3 don't forget to handle the case for self-hosted sites on WPAndroid also. I can give you login info to my self hosted site if you need for testing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the heads up @pinarol!

@pinarol pinarol requested a review from SergioEstevao April 24, 2019 17:32
Copy link
Copy Markdown
Contributor

@SergioEstevao SergioEstevao left a comment

Choose a reason for hiding this comment

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

Working great on iOS!

@daniloercoli
Copy link
Copy Markdown
Contributor

Cancel a video upload by tapping the image

Hey @SergioEstevao 👋

Did you try to tap on an already uploaded video, when there is another video currently uploading?
On Android, when I tapped on an already uploaded video, and the other one was in progress, i saw the following popup:
device-2019-04-30-115318

Remove is OK, but Retry should not be there, as well as Retry All.

@SergioEstevao
Copy link
Copy Markdown
Contributor

Did you try to tap on an already uploaded video, when there is another video currently uploading?

@daniloercoli on iOS it's working ok, when you tap on already it opens a full screen preview of tha video.

If you tap on a current uploading video you get a an action sheet asking to cancel upload or dismiss.

pinarol added 3 commits May 6, 2019 18:50
# Conflicts:
#	Podfile
#	Podfile.lock
Otherwise local url remains if upload completes outside of gutenberg editor
@pinarol
Copy link
Copy Markdown
Contributor Author

pinarol commented May 9, 2019

hey @etoledom, @SergioEstevao 👋 I pushed a new commit to address this:

2. Close post with an ongoing video upload.
This in general works well, but there's a particular case where there's an issue:
When the upload finishes in the Post List, and then the post is open again, the video block is loaded with a local URL.

I made a video to showcase the problem.

About the crash on background thread I opened an issue for Groundskeeping: #11664

original comment too see more context: wordpress-mobile/gutenberg-mobile#854 (review)


extension AbstractPost {

func fetchRemoteVideoURL(for media: Media, completion: @escaping ( Result<(videoURL: URL, posterURL: URL?)> ) -> Void) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is the best place for this method because of:

  • The method isn't related to the Post object in anyway, if we are doing an extension maybe it should be to the Media object.
  • Even as an extension to the media object it will be a bit out of place because it's creating a MediaService inside and the entity objects should avoid creating service, it should be the other way around.

What about creating a helper class? What was the initial reason to move it here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually I don't have a strong reason, I was hesitant about putting it here too. Yes I can put that into a helper

@etoledom
Copy link
Copy Markdown
Contributor

etoledom commented May 9, 2019

Fwiw, this fixes the issue on my tests 🎉

@pinarol pinarol requested a review from SergioEstevao May 9, 2019 10:08
@pinarol
Copy link
Copy Markdown
Contributor Author

pinarol commented May 9, 2019

@SergioEstevao Could you please re-review? (I moved the method to EditorMadiaUtility)

Copy link
Copy Markdown
Contributor

@SergioEstevao SergioEstevao left a comment

Choose a reason for hiding this comment

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

Looking good!

@etoledom
Copy link
Copy Markdown
Contributor

@pinarol - I've found a new issue uploading multiple videos. This wasn't happening before so it seems to be a regression from the last update:

Intent: Upload many different videos.
Result: All videos uploaded are the same one.
Steps:

  • Create a few empty video blocks.
  • Add a different video on each of them (hopefully heavy ones).
  • Publish the post before the videos finish uploading.
  • In the Post List, when the post is finally published, open it again.
  • All videos will be the same one (the last one uploaded).

I believe that this happens even if some videos already finished uploading.

@pinarol
Copy link
Copy Markdown
Contributor Author

pinarol commented May 10, 2019

hey @marecar3 could you be able to check if this is happening on Android ? #11454 (comment)

if so at least we'd know where to look for.

}
switch media.mediaType {
case .video:
EditorMediaUtility.fetchRemoteVideoURL(for: media, in: post) { [weak self] (result) in
Copy link
Copy Markdown
Contributor Author

@pinarol pinarol May 10, 2019

Choose a reason for hiding this comment

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

@SergioEstevao I have second thoughts about where to put this service call because this is being called for classical editor posts also. is there any chance you know a better place to put this?

case .error:
self?.change(post: post, status: .failed)
case .success(let value):
media.remoteURL = value.videoURL.absoluteString
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

also I am not sure if that's a right thing to change a managed object like this :(

@marecar3
Copy link
Copy Markdown
Contributor

hey @marecar3 could you be able to check if this is happening on Android ? #11454 (comment)

if so at least we'd know where to look for.

Hey, @etoledom @pinarol I have tested this scenario on WPAndroid, and is seems that everything is working fine. I have tested with 2 videos and when the upload was finished in the Post list, I opened the Post and both videos were different.

@SergioEstevao
Copy link
Copy Markdown
Contributor

@pinarol - I've found a new issue uploading multiple videos. This wasn't happening before so it seems to be a regression from the last update:

Intent: Upload many different videos.
Result: All videos uploaded are the same one.
Steps:

* Create a few empty video blocks.

* Add a different video on each of them (hopefully heavy ones).

* Publish the post before the videos finish uploading.

* In the Post List, when the post is finally published, open it again.

* All videos will be the same one (the last one uploaded).

I believe that this happens even if some videos already finished uploading.

@etoledom I pushed some changes to the PR that address this issue, do you mind to retest it?

@marecar3
Copy link
Copy Markdown
Contributor

Hey @SergioEstevao nice work here! I have tested this and it's working good :)

cc @etoledom @pinarol

@marecar3 marecar3 merged commit c0ddace into develop May 12, 2019
@marecar3 marecar3 deleted the gutenberg/video-upload branch May 12, 2019 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gutenberg Editing and display of Gutenberg blocks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Video block (first iteration)

6 participants