#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 ### Fixed
- rendering of SVG with large header - 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 ## <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 highlightJumpDelay = Duration(milliseconds: 400);
static const highlightScrollInitDelay = Duration(milliseconds: 800); static const highlightScrollInitDelay = Duration(milliseconds: 800);
static const motionPhotoAutoPlayDelay = Duration(milliseconds: 700); static const motionPhotoAutoPlayDelay = Duration(milliseconds: 700);
static const videoPauseAppInactiveDelay = Duration(milliseconds: 300);
static const videoOverlayHideDelay = Duration(milliseconds: 500); static const videoOverlayHideDelay = Duration(milliseconds: 500);
static const videoProgressTimerInterval = Duration(milliseconds: 300); static const videoProgressTimerInterval = Duration(milliseconds: 300);
static const doubleBackTimerDelay = Duration(milliseconds: 1000); static const doubleBackTimerDelay = Duration(milliseconds: 1000);

View file

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

View file

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