Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Pause new video player if app is not in fg

ashilkn0753b59e4a93
diff --git a/mobile/lib/ui/viewer/file/video_widget_native.dart b/mobile/lib/ui/viewer/file/video_widget_native.dart
index 7b3502a5eb..17e48d4dc8 100644
--- a/mobile/lib/ui/viewer/file/video_widget_native.dart
+++ b/mobile/lib/ui/viewer/file/video_widget_native.dart
@@ -52,10 +52,8 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
late StreamSubscription<PauseVideoEvent> pauseVideoSubscription;
bool _isGuestView = false;
late final StreamSubscription<GuestViewEvent> _guestViewEventSubscription;
-
NativeVideoPlayerController? _controller;
String? _filePath;
-
String? duration;
double? aspectRatio;
final _isPlaybackReady = ValueNotifier(false);
@@ -111,6 +109,15 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
});
}
+ @override
+ void didChangeAppLifecycleState(AppLifecycleState state) {
+ if (state != AppLifecycleState.resumed) {
+ if (_controller?.playbackInfo?.status == PlaybackStatus.playing) {
+ _controller?.pause();
+ }
+ }
+ }
+
@override
void dispose() {
//https://github.com/fluttercandies/flutter_photo_manager/blob/8afba2745ebaac6af8af75de9cbded9157bc2690/README.md#clear-caches