Quellcode durchsuchen

feat(media-kit): enable full screen mode for all devices when video is playing

ashilkn vor 1 Jahr
Ursprung
Commit
aeddaf9639

+ 9 - 11
lib/ui/viewer/file/detail_page.dart

@@ -181,16 +181,11 @@ class _DetailPageState extends State<DetailPage> {
               });
             }
           },
-          //Noticed that when the video is seeked, the video pops and moves the
-          //seek bar along with it and it happens when bottomPadding is 0. So we
-          //don't toggle full screen for cases where this issue happens.
-          playbackCallback: bottomPadding != 0
-              ? (isPlaying) {
-                  Future.delayed(Duration.zero, () {
-                    _toggleFullScreen();
-                  });
-                }
-              : null,
+          playbackCallback: (isPlaying) {
+            Future.delayed(Duration.zero, () {
+              _toggleFullScreen(shouldEnable: isPlaying);
+            });
+          },
           backgroundDecoration: const BoxDecoration(color: Colors.black),
         );
         return GestureDetector(
@@ -244,7 +239,10 @@ class _DetailPageState extends State<DetailPage> {
     return false;
   }
 
-  void _toggleFullScreen() {
+  void _toggleFullScreen({bool? shouldEnable}) {
+    if (shouldEnable != null) {
+      if (_enableFullScreenNotifier.value == shouldEnable) return;
+    }
     _enableFullScreenNotifier.value = !_enableFullScreenNotifier.value;
 
     Future.delayed(const Duration(milliseconds: 125), () {

+ 1 - 0
lib/ui/viewer/file/file_widget.dart

@@ -47,6 +47,7 @@ class FileWidget extends StatelessWidget {
       return VideoWidgetNew(
         file,
         tagPrefix: tagPrefix,
+        playbackCallback: playbackCallback,
       );
     } else {
       Logger('FileWidget').severe('unsupported file type ${file.fileType}');

+ 7 - 0
lib/ui/viewer/file/video_widget_new.dart

@@ -19,9 +19,11 @@ import "package:photos/utils/toast_util.dart";
 class VideoWidgetNew extends StatefulWidget {
   final EnteFile file;
   final String? tagPrefix;
+  final Function(bool)? playbackCallback;
   const VideoWidgetNew(
     this.file, {
     this.tagPrefix,
+    this.playbackCallback,
     super.key,
   });
 
@@ -64,6 +66,11 @@ class _VideoWidgetNewState extends State<VideoWidgetNew> {
         }
       });
     }
+    player.stream.playing.listen((event) {
+      if (widget.playbackCallback != null) {
+        widget.playbackCallback!(event);
+      }
+    });
   }
 
   @override