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

Media Picker: Choose From Device: Fix Video thumbnails do not load #15411

Merged
merged 7 commits into from
Oct 12, 2021

Conversation

ashiagr
Copy link
Contributor

@ashiagr ashiagr commented Oct 4, 2021

Fixes #14618 & #15306

This PR displays thumbnails for local videos having URLs with content URI protocol, detects them as videos, and plays them on the media preview screen.

  • VideoLoader did not take into consideration local videos with content URI protocol when checking for media size, and when such URLs were passed to it, it failed with MalformedURLException. To address this, file size for such files is checked according to the suggested approach in 258f726.

  • Real path for local URI is passed in 983b21b so that they get detected as videos in MediaPreviewFragment via MediaUtils.isVideo otherwise they were displayed as images.

  • Once detected as local videos, they're played using ExoPlayer adjustments for local videos in 46e6aeb.

To test:

  1. Launch the app and go to My Site -> Post
  2. Add a Video block
  3. Select “Choose from device”
  4. Notice that media picker is displayed and thumbnails are loaded
  5. Long press a thumbnail
  6. Notice that video plays properly

Regression Notes

  1. Potential unintended areas of impact
    VideoLoader is used for both remote and local videos

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Tested manually that thumbnails for local as well remote videos are loaded properly and videos gets played as well

  3. What automated tests I added (or what prevented me from doing so)
    None

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

This is done to allow previewing files with content URI prototocol which are not detected as videos in MediaPreviewFragment using MediaUtils.isVideo method.
@ashiagr ashiagr added the Media label Oct 4, 2021
@ashiagr ashiagr added this to the 18.5 milestone Oct 4, 2021
@ashiagr ashiagr requested a review from zwarm October 4, 2021 12:19
@ashiagr ashiagr self-assigned this Oct 4, 2021
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Oct 4, 2021

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Oct 4, 2021

You can test the changes on this Pull Request by downloading the APKs:

@ashiagr ashiagr removed the request for review from zwarm October 4, 2021 13:49
Copy link
Contributor

@zwarm zwarm left a comment

Choose a reason for hiding this comment

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

@ashiagr - The code looks fine; however not all of my thumbnails load in the list. I see "Failed to load resource" glide errors.

I've attached a copy of my logcat + a video of what I am seeing in the app. I thought perhaps it was just large videos, but scrolling down and then PTR doesn't fix it.

screen-20211004-134523.mp4

logcat.txt

@ashiagr
Copy link
Contributor Author

ashiagr commented Oct 5, 2021

@zwarm, I checked it briefly. I have smaller videos on my test device so wasn't able to notice it. For one of the failing videos , I noticed length of the file was 14564617 which was greater than SIZE_LIMIT_10_MB = 10485760. So I believe it is due to large file sizes where thumbnails don't load.

While restricting previews based on video size is not an ideal solution, this PR only adds additional support for local videos with content URIs otherwise none of the local videos can be previewed in the media grid.

Regarding the Glide issue, whenever imageManager.loadThumbnailFromVideoUrl -> fallbackAction is executed, currently R.color.placeholder is directly loaded using Glide whereas it seems Glide expects a color drawable. This can be confirmed from the logs in the file you shared:

Cause (1 of 1): class java.io.FileNotFoundException: Resource does not exist: android.resource://org.wordpress.android.prealpha/color/placeholder

I wasn't able to fix it + failing test today. I'll ping you again as soon as I'm able to work on it.

Thank you so much, for testing it out! 🙏

@zwarm
Copy link
Contributor

zwarm commented Oct 5, 2021

@ashiagr - Since this PR only addresses the URI issue, should we create a new issue for files over 10MB concentrating on choosing between not showing thumbnails at or or showing a message that they are too large? I don't have the answer, but would love to open it for discussion.

I'll retest when you are ready. Thanks. :)

@ashiagr
Copy link
Contributor Author

ashiagr commented Oct 12, 2021

Hey @zwarm!

I've created a new issue to find out a way to load large videos thumbnails: #15443.

Also fixed failing test (1883de3) and Glide issue (cdb0026).

This is now ready for another look. 🙏

Copy link
Contributor

@zwarm zwarm left a comment

Choose a reason for hiding this comment

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

Thank you @ashiagr . All is working as expected - no more glide error. Thanks for pulling together a new issue for the thumbnail.

@zwarm zwarm merged commit 0ae4aa4 into develop Oct 12, 2021
@zwarm zwarm deleted the issue/15306-fix-local-video-thumbnail-play-issue branch October 12, 2021 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media Picker: Choose From Device: Video thumbnails do not load
2 participants