Commit Graph

9 Commits

Author SHA1 Message Date
mcclure 70725fd75b
Regularize show/hide logic for video player scrub/play controls (fixes #4073) (#4117)
When viewing a video in Tusky, there is a top toolbar where the
description is shown and the bottom toolbar where play, forward,
backward, and scrub controls are found. In both Tusky 23 and the new
media3 video player code, the logic for showing these toolbars is
*unrelated*; Tusky catches tap events and shows and hides the
description, and the Android media library separately catches tap events
and shows and hides the bottom toolbar. Meanwhile, Tusky and the Android
media library each separately manage a set of logic for auto-hiding
their respective toolbars after a certain number of seconds has passed.
This all results in several problems:

- The top and bottom toolbars can desync, so that one is visible and the
other is not, and tapping to show/hide after this will only swap which
one is visible. This happens *every* time you switch to another
application then back to Tusky while the video player is up.
- You can also desync the top and bottom toolbars in this way by simply
tapping very rapidly.
- The autohide logic was difficult for us to control or customize,
because it was partially hidden inside the Android libraries (relevant
because under media3, the autohide delay increased from 3 to something
like 5 or 6 seconds).

In this patch, I disabled all auto- and tap-based show/hide logic in
media3 and set the Tusky-side show/hide to directly control the media3
toolbar. I then audited the code with printfs until I understood the
state machine of show/hide, and removed anything irrational (some code
was either unreachable, or redundant; either these lines were broken in
the media3 transition, or they never worked).¹

While doing this, I made two policy changes:

- As discussed on Matrix, the autohide delay is now 4 seconds. (In
discussions with users on Mastodon, some complained the previous 3
seconds was too short; but in my opinion and [I think?] charlag's, the
new 5 seconds is too long).
- In the pre-existing code, if the user has hidden the controls, and
they switch to another app and back, the controls display for 4 seconds
then re-hide themselves, just like if the video had been presented for
the first time. I think this is good and kept it— *however* I made a
decision if the user intentionally taps to display the controls, *then*
switches to another app and back, the controls should *not* auto-hide,
because the user most recently requested those controls be shown.

Tests I performed on the final PR (successfully):

- Start video. Expect: toolbar+description hides after 4 seconds.
- Start video. Pause. Resume. Expect: t+d hides after 4 seconds.
- Start video. Wait 4 seconds until t+d hide. Switch to other app.
Switch back. Expect: t+d reappears, then hides after 4 seconds.
- Start video. Wait 4 seconds until t+d hide. Tap to show t+d. Switch to
other app. Switch back. Expect: t+d appear, do NOT autohide.
- Start video. Before 4 seconds up, switch to other app. Switch back.
Expect: t+d reappears, then hides after 4 seconds.
- Start video. Pause. Resume. Before 4 seconds up, switch to other app.
Switch back. Expect: t+d reappears, then hides after 4 seconds.
- Start video. Wait 4 seconds until t+d hide. Tap rapidly over and over
for many seconds. Expect: Nothing weird
- Start *audio*. Expect: At no point does controller autohide, not even
if I switch to another app and back, but I can hide it by manually
tapping

These tests were performed on Android 13. There is an entirely separate
`Build.VERSION.SDK_INT <= 23` path I did not test, but Android Studio
says this is dead code (I think it thinks our minimum SDK is higher than
that?)

---

<small>¹ Incidentally, the underlying cause of #4073 (the show/resume
part of it anyway) turned out to be that the STATE_READY event was being
received not just on video load but also a second time on app resume,
causing certain parts of the initialization code to run a second time
although the fragment had already been fully initialized.</small>
2023-11-23 08:32:01 +01:00
Nik Clayton 8529f309ff
Migrate to androidx-media3 video player (#3857)
Behaviour is consistent with previous player except that:

- Swapping apps while a video is playing, and then returning to Tusky,
will keep the seek position in the video instead of returning to the
start
- The controls/media description can be shown by tapping anywhere, not
just on the video itself
- The media description is on-screen for the same duration as the player
controls (5 seconds here, 3 seconds in the previous code)
- The user has options to control the playback speed
- Rotating the device does not squash/stretch the video
- Show the media preview when playing audio-only files

Fixes https://github.com/tuskyapp/Tusky/issues/3329,
https://github.com/tuskyapp/Tusky/issues/3141,
https://github.com/tuskyapp/Tusky/issues/3126,
https://github.com/tuskyapp/Tusky/issues/2753,
https://github.com/tuskyapp/Tusky/issues/3508,
https://github.com/tuskyapp/Tusky/issues/3291

---------

Co-authored-by: mcc <andi.m.mcclure@gmail.com>
2023-08-10 19:31:55 +02:00
Levi Bard 45598cf047
Audio caption improvements (#2220)
* Fix caption display in audio player

* Make video/audio description scrollable

* Constrain the maximum size of media label previews
2021-09-17 21:55:54 +02:00
Vivianne a7c1345085 Small changes to the media player (#1572)
* Resolving some issues with media playback.

* Changing ViewVideoFragment so that it fully handles autohiding the
  media controller, allowing consistency between it and the toolbar

* Fixed an issue where the toolbar and description were not fading in

* Do not hide the toolbar/media player if the video is loading or paused

* Created "ExposedPlayPausedVideoView" to allow hooking play/pause

* Fix back button when viewing videos

* Back button did not work if video controls were visible.

* Tweak audio player

* Always show the controls when audio begins playing

* Do not auto-hide the controls if the player is playing audio

* Address PR comments

* Use overloaded constructor
* Remove m prefix

* Fix subtle media player issues

* Fix audio player incorrectly auto-hiding after hiding/showing toolbar

* Only subscribe touch listener once content is ready
  - Prevents top toolbar visibility from getting out of phase with audio player visibility if hidden during load
2020-01-16 19:01:02 +01:00
Konrad Pozniak 78b5aa8baf
Upgrade api level to Android 10, implement new sharing api (#1537)
* upgrade api level to Android 10, resolve compile errors

* use androidx.preference.PreferenceManager instead of deprecated platform class

* add hyphenation to important TextViews

*  setBottomSheetCallback -> addBottomSheetCallback

* implement new sharing api

* improve TuskyTileService so it shows account picker when multiple accounts are present

* delete unused AccountChooserService

* fix test

* improve ShareShortcutHelper

* remove debug log statement

* improve image loading fallback behavior in ShareShortcutHelper

* improve behavior on foldable devices
2019-10-22 21:18:20 +02:00
Konrad Pozniak fe304b4e83
fix videos not always keeping aspect ratio (#1508) 2019-10-01 18:24:09 +02:00
Konrad Pozniak 8b85df08bd
upgrade build tools and enable r8 full mode (#1198)
* upgrade build tools and enable r8 full mode

* fix media description in fragment_view_video
2019-04-20 17:44:54 +02:00
Konrad Pozniak a445c12094
Upgrade to AndroidX, move to MaterialComponents theme (#953)
* upgrade to AndroidX, upgrade libraries

* move to MaterialComponents theme

* make sure the compose button looks good everywhere

* fix tollbar title/button alignment on tablet

* move to new material color theming, consolidate colors and themes

* fix build, fix imports

* set error on TextInputLayout instead of EditText

* fix imports, TootButton when

* improve snackbar style

* fix task description color
2018-12-17 15:25:35 +01:00
Levi Bard 952d2a6512 Refactor media views (#866)
* Migrate ImagePagerAdapter to kotlin

* Migrate ViewMediaFragment to kotlin

* Make images and videos share the same activity/pager

* Show descriptions above videos

* Cleanup

* Address code review feedback

* Migrate media fragments to constraint layout
2018-10-15 19:56:11 +02:00