Sfoglia il codice sorgente

fix(video-player): use video_player instead of media_kit for videos if os is grapheneOS or divestOS

ashilkn 1 anno fa
parent
commit
0b391a704a
2 ha cambiato i file con 26 aggiunte e 11 eliminazioni
  1. 16 11
      lib/ui/viewer/file/file_widget.dart
  2. 10 0
      lib/utils/device_info.dart

+ 16 - 11
lib/ui/viewer/file/file_widget.dart

@@ -2,8 +2,10 @@ import 'package:flutter/material.dart';
 import 'package:logging/logging.dart';
 import 'package:photos/models/file/file.dart';
 import 'package:photos/models/file/file_type.dart';
+import "package:photos/ui/viewer/file/video_widget.dart";
 import "package:photos/ui/viewer/file/video_widget_new.dart";
 import "package:photos/ui/viewer/file/zoomable_live_image_new.dart";
+import "package:photos/utils/device_info.dart";
 
 class FileWidget extends StatelessWidget {
   final EnteFile file;
@@ -38,17 +40,20 @@ class FileWidget extends StatelessWidget {
         key: key ?? ValueKey(fileKey),
       );
     } else if (file.fileType == FileType.video) {
-      // return VideoWidget(
-      //   file,
-      //   autoPlay: autoPlay ?? false, // Autoplay if it was opened directly
-      //   tagPrefix: tagPrefix,
-      //   playbackCallback: playbackCallback,
-      // );
-      return VideoWidgetNew(
-        file,
-        tagPrefix: tagPrefix,
-        playbackCallback: playbackCallback,
-      );
+      if (isCompatibleWithMediaKit()) {
+        return VideoWidgetNew(
+          file,
+          tagPrefix: tagPrefix,
+          playbackCallback: playbackCallback,
+        );
+      } else {
+        return VideoWidget(
+          file,
+          autoPlay: autoPlay ?? false, // Autoplay if it was opened directly
+          tagPrefix: tagPrefix,
+          playbackCallback: playbackCallback,
+        );
+      }
     } else {
       Logger('FileWidget').severe('unsupported file type ${file.fileType}');
       return const Icon(Icons.error);

+ 10 - 0
lib/utils/device_info.dart

@@ -51,3 +51,13 @@ Future<bool> isAndroidSDKVersionLowerThan(int inputSDK) async {
     return false;
   }
 }
+
+bool isCompatibleWithMediaKit() {
+  final os = Platform.operatingSystem.toLowerCase();
+  if (os == "grapheneos" || os == "divestos") {
+    Logger("device_info").info("os is $os, using video_player for videos");
+    return false;
+  }
+  Logger("device_info").info("os is $os, using media_kit for videos");
+  return true;
+}