#957 fixed video pause when changing device orientation on Android API33

This commit is contained in:
Thibault Deckers 2024-04-24 19:57:59 +02:00
parent 65e224ef57
commit dffa54239f
4 changed files with 15 additions and 3 deletions

View file

@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
### Fixed
- rendering of SVG with large header
- stopping video playback when changing device orientation on Android >=13
## <a id="v1.10.9"></a>[v1.10.9] - 2024-04-14

View file

@ -60,6 +60,7 @@ class ADurations {
static const highlightJumpDelay = Duration(milliseconds: 400);
static const highlightScrollInitDelay = Duration(milliseconds: 800);
static const motionPhotoAutoPlayDelay = Duration(milliseconds: 700);
static const videoPauseAppInactiveDelay = Duration(milliseconds: 300);
static const videoOverlayHideDelay = Duration(milliseconds: 500);
static const videoProgressTimerInterval = Duration(milliseconds: 300);
static const doubleBackTimerDelay = Duration(milliseconds: 1000);

View file

@ -387,6 +387,7 @@ class _AvesAppState extends State<AvesApp> with WidgetsBindingObserver {
break;
}
case AppLifecycleState.resumed:
availability.onResume();
RecentlyAddedFilter.updateNow();
_mediaStoreSource.checkForChanges();
break;

View file

@ -80,7 +80,7 @@ class _EntryViewerStackState extends State<EntryViewerStack> with EntryViewContr
late VideoActionDelegate _videoActionDelegate;
final ValueNotifier<HeroInfo?> _heroInfoNotifier = ValueNotifier(null);
bool _isEntryTracked = true;
Timer? _overlayHidingTimer;
Timer? _overlayHidingTimer, _videoPauseTimer;
@override
bool get isViewingImage => _currentVerticalPage.value == imagePage;
@ -199,6 +199,7 @@ class _EntryViewerStackState extends State<EntryViewerStack> with EntryViewContr
_verticalScrollNotifier.dispose();
_heroInfoNotifier.dispose();
_stopOverlayHidingTimer();
_stopVideoPauseTimer();
AvesApp.lifecycleStateNotifier.removeListener(_onAppLifecycleStateChanged);
_unregisterWidget(widget);
super.dispose();
@ -335,9 +336,10 @@ class _EntryViewerStackState extends State<EntryViewerStack> with EntryViewContr
// paused: when switching to another app
// detached: when app is without a view
viewerController.autopilot = false;
_stopVideoPauseTimer();
pauseVideoControllers();
case AppLifecycleState.resumed:
availability.onResume();
_stopVideoPauseTimer();
case AppLifecycleState.hidden:
// hidden: transient state between `inactive` and `paused`
break;
@ -354,10 +356,17 @@ class _EntryViewerStackState extends State<EntryViewerStack> with EntryViewContr
// ensure playback, in case lifecycle paused/resumed events happened when switching to PiP
await playingController?.play();
} else {
await pauseVideoControllers();
_startVideoPauseTimer();
}
}
void _startVideoPauseTimer() {
_stopVideoPauseTimer();
_videoPauseTimer = Timer(ADurations.videoPauseAppInactiveDelay, pauseVideoControllers);
}
void _stopVideoPauseTimer() => _videoPauseTimer?.cancel();
Widget _decorateOverlay(Widget overlay) {
return ValueListenableBuilder<double>(
valueListenable: _overlayAnimationController,