Skip to content

armgit / ente

Public Imported from GitHub
0

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

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

ashilkn0b391a704af4
diff --git a/lib/ui/viewer/file/file_widget.dart b/lib/ui/viewer/file/file_widget.dart
index 5f1fba2904..5928c16eda 100644
--- a/lib/ui/viewer/file/file_widget.dart
+++ b/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);
diff --git a/lib/utils/device_info.dart b/lib/utils/device_info.dart
index 1e713be7d5..b83ddb8509 100644
--- a/lib/utils/device_info.dart
+++ b/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;
+}