diff --git a/CHANGELOG.md b/CHANGELOG.md index 18b8d37c2..25b9eb357 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ## [v1.10.9] - 2024-04-14 diff --git a/lib/theme/durations.dart b/lib/theme/durations.dart index 56e852d78..9ba4ab37c 100644 --- a/lib/theme/durations.dart +++ b/lib/theme/durations.dart @@ -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); diff --git a/lib/widgets/aves_app.dart b/lib/widgets/aves_app.dart index 5b8d36bc2..683e4b31b 100644 --- a/lib/widgets/aves_app.dart +++ b/lib/widgets/aves_app.dart @@ -387,6 +387,7 @@ class _AvesAppState extends State with WidgetsBindingObserver { break; } case AppLifecycleState.resumed: + availability.onResume(); RecentlyAddedFilter.updateNow(); _mediaStoreSource.checkForChanges(); break; diff --git a/lib/widgets/viewer/entry_viewer_stack.dart b/lib/widgets/viewer/entry_viewer_stack.dart index 82a2444de..1e73c1e8b 100644 --- a/lib/widgets/viewer/entry_viewer_stack.dart +++ b/lib/widgets/viewer/entry_viewer_stack.dart @@ -80,7 +80,7 @@ class _EntryViewerStackState extends State with EntryViewContr late VideoActionDelegate _videoActionDelegate; final ValueNotifier _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 with EntryViewContr _verticalScrollNotifier.dispose(); _heroInfoNotifier.dispose(); _stopOverlayHidingTimer(); + _stopVideoPauseTimer(); AvesApp.lifecycleStateNotifier.removeListener(_onAppLifecycleStateChanged); _unregisterWidget(widget); super.dispose(); @@ -335,9 +336,10 @@ class _EntryViewerStackState extends State 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 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( valueListenable: _overlayAnimationController,