Skip to content

Video preview: use fullscreen dialog for video instead of new activity#11089

Merged
AlvaroBrey merged 5 commits intomasterfrom
fix/video-fullscreen-buffer
Nov 29, 2022
Merged

Video preview: use fullscreen dialog for video instead of new activity#11089
AlvaroBrey merged 5 commits intomasterfrom
fix/video-fullscreen-buffer

Conversation

@AlvaroBrey
Copy link
Copy Markdown
Member

@AlvaroBrey AlvaroBrey commented Nov 24, 2022

This allows transfering the playback directly between Player views, thus avoiding creating
a new ExoPlayer, re-loading the stream, having to pass playing status/current position, etc.

In summary, this provides a much more seamless experience when switching to/from fullscreen.

Additionally:

  • Always enable buffering animation so it's clear when a video is loading
  • Add padding to fullscreen duration numbers so they don't get cut off on rounded screens
  • Tests written, or not not needed

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 24, 2022

Codecov Report

Merging #11089 (4fc73f0) into master (f9e500b) will increase coverage by 0.55%.
The diff coverage is 0.00%.

❗ Current head 4fc73f0 differs from pull request most recent head 3f990c3. Consider uploading reports for the commit 3f990c3 to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #11089      +/-   ##
============================================
+ Coverage     30.87%   31.43%   +0.55%     
- Complexity     3280     3320      +40     
============================================
  Files           564      564              
  Lines         41616    41618       +2     
  Branches       5657     5638      -19     
============================================
+ Hits          12849    13082     +233     
+ Misses        26833    26547     -286     
- Partials       1934     1989      +55     
Impacted Files Coverage Δ
...java/com/nextcloud/client/di/ComponentsModule.java 0.00% <ø> (ø)
...cloud/android/ui/activity/FileDisplayActivity.java 27.08% <0.00%> (-0.09%) ⬇️
...cloud/android/ui/preview/PreviewMediaFragment.java 0.00% <0.00%> (ø)
...android/ui/preview/PreviewVideoFullscreenDialog.kt 0.00% <0.00%> (ø)
.../com/owncloud/android/ui/dialog/LoadingDialog.java 0.00% <0.00%> (-95.24%) ⬇️
...com/owncloud/android/ui/activity/FileActivity.java 22.64% <0.00%> (-2.97%) ⬇️
...cloud/android/ui/helpers/FileOperationsHelper.java 5.87% <0.00%> (-2.28%) ⬇️
...wncloud/android/providers/FileContentProvider.java 72.22% <0.00%> (-1.86%) ⬇️
...a/com/owncloud/android/utils/FileStorageUtils.java 55.88% <0.00%> (-1.84%) ⬇️
...ud/android/providers/DocumentsStorageProvider.java 52.13% <0.00%> (-0.54%) ⬇️
... and 23 more

@tobiasKaminsky
Copy link
Copy Markdown
Member

tobiasKaminsky commented Nov 25, 2022

That is a super idea!
I tested it with two videos

  • one from $internet: looks good
  • one captured on same emulator: ratio is totally off

2022-11-25-095228

@AlvaroBrey
Copy link
Copy Markdown
Member Author

AlvaroBrey commented Nov 25, 2022

  • one captured on same emulator: ratio is totally off

This looks like a pre-existing bug that just shows here easier. The video that shows the problem is stored in horizontal but has a rotation metadata. There was a bug in Android with this, but it was patched in Android 11 (API 30). Reference: google/ExoPlayer#1482 There are other bugs with SurfaceView and metadata rotation, and workarounds with TextureView.

In the master branch and previous releases, this is reproducible by:

  • Going to fullscreen and then back
  • Opening preview fragment, leaving the app by Home and then coming back from Recents. Video (stable-3.22):
    rotation.webm

It looks like the bug is only triggered when the video is "resumed" on a surface, either a new one or the same one it was already on.

I can reproduce this in api 29 and lower, but can't reproduce in a higher API level. I can also only reproduce it with the 29 - Google Play image, not with the 29 - google APIs one. Fix may have been backported?

There may be a possible (but fairly complicated) workaround by using TextureView and applying the rotation manually. This would have to be confined to android <=29, as TextureView is more battery-consuming than the default SurfaceView.

@tobiasKaminsky what do you think we should do here? Attempt the workaround for API <29, or just let it be? It only happens with some <=29 devices, and only with videos with metadata rotation.

@tobiasKaminsky
Copy link
Copy Markdown
Member

First, great that you figured it out!

@tobiasKaminsky what do you think we should do here? Attempt the workaround for API <29, or just let it be? It only happens with some <=29 devices, and only with videos with metadata rotation.

Actually I have no idea either. <=29 is quite a lot of users, which might be not a problem, depending how many videos actually use this rotation info.

There may be a possible (but fairly complicated) workaround by using TextureView and applying the rotation manually. This would have to be confined to android <=29, as TextureView is more battery-consuming than the default SurfaceView.

How long would this roughly take?

Then we could first merge without above workaround, but when to many users suffer by it, we can use this workaround or revert.

Another option would be to have this only for >29 enabled, and once we drop 28 support, we can change it.

@AlvaroBrey
Copy link
Copy Markdown
Member Author

Another workaround idea: in devices with api <= 29, keep using the old approach (new exoplayer rather than transferring the old one). This will invalidate the UX gains for api 29 and under, though.

@AlvaroBrey
Copy link
Copy Markdown
Member Author

How long would this roughly take?

I have no idea :( I think the workaround in my previous comment may be preferrable

@AlvaroBrey
Copy link
Copy Markdown
Member Author

Rotation bug worked around in 4fc73f0

@AlvaroBrey
Copy link
Copy Markdown
Member Author

/rebase

This allows transfering the playback directly between Player views, thus avoiding creating
a new ExoPlayer, re-starting the stream, having to pass playing status/current position, etc.

Additionally:
- Always enable buffering animation so it's clear when a video is loading
- Add padding to fullscreen duration numbers so they don't get cut off on rounded screens

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
…pause the video while transfer is happening

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
See comments in added code for explanation

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
@nextcloud-command nextcloud-command force-pushed the fix/video-fullscreen-buffer branch from 4fc73f0 to 3f990c3 Compare November 28, 2022 19:22
@github-actions
Copy link
Copy Markdown

Codacy

Lint

TypemasterPR
Warnings8282
Errors00

SpotBugs

CategoryBaseNew
Bad practice2727
Correctness4545
Dodgy code336336
Internationalization99
Multithreaded correctness99
Performance5858
Security1818
Total502502

@github-actions
Copy link
Copy Markdown

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/11089.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@tobiasKaminsky
Copy link
Copy Markdown
Member

Works perfectly fine with "broken" video.

@AlvaroBrey AlvaroBrey merged commit f74f592 into master Nov 29, 2022
@delete-merged-branch delete-merged-branch Bot deleted the fix/video-fullscreen-buffer branch November 29, 2022 12:33
@AlvaroBrey AlvaroBrey added this to the Nextcloud App 3.24.0 milestone Nov 29, 2022
surinder-tsys added a commit to nextmcloud/android that referenced this pull request Nov 30, 2022
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.

2 participants