#737 keep playing slideshow when losing focus but app is still visible (e.g. split screen)

This commit is contained in:
Thibault Deckers 2024-01-06 23:36:24 +01:00
parent b57253c251
commit 694c5941cb
2 changed files with 8 additions and 2 deletions

View file

@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
### Changed ### Changed
- Info: strip `unlocated` filter from context collection when editing location via map - Info: strip `unlocated` filter from context collection when editing location via map
- Slideshow: keep playing when losing focus but app is still visible (e.g. split screen)
## <a id="v1.10.2"></a>[v1.10.2] - 2023-12-24 ## <a id="v1.10.2"></a>[v1.10.2] - 2023-12-24

View file

@ -290,19 +290,24 @@ class _EntryViewerStackState extends State<EntryViewerStack> with EntryViewContr
void _onAppLifecycleStateChanged() { void _onAppLifecycleStateChanged() {
switch (AvesApp.lifecycleStateNotifier.value) { switch (AvesApp.lifecycleStateNotifier.value) {
case AppLifecycleState.inactive: case AppLifecycleState.inactive:
// inactive: when losing focus
_onAppInactive(); _onAppInactive();
case AppLifecycleState.hidden:
case AppLifecycleState.paused: case AppLifecycleState.paused:
case AppLifecycleState.detached: case AppLifecycleState.detached:
// paused: when switching to another app
// detached: when app is without a view
viewerController.autopilot = false;
pauseVideoControllers(); pauseVideoControllers();
case AppLifecycleState.resumed: case AppLifecycleState.resumed:
availability.onResume(); availability.onResume();
case AppLifecycleState.hidden:
// hidden: transient state between `inactive` and `paused`
break;
} }
} }
Future<void> _onAppInactive() async { Future<void> _onAppInactive() async {
final playingController = context.read<VideoConductor>().getPlayingController(); final playingController = context.read<VideoConductor>().getPlayingController();
viewerController.autopilot = false;
bool enabledPip = false; bool enabledPip = false;
if (settings.videoBackgroundMode == VideoBackgroundMode.pip) { if (settings.videoBackgroundMode == VideoBackgroundMode.pip) {
enabledPip |= await _enablePictureInPicture(); enabledPip |= await _enablePictureInPicture();