Browse Source

Upgrade media kit (#1443)

Neeraj Gupta 1 year ago
parent
commit
cc4008ec6e
5 changed files with 9 additions and 43 deletions
  1. 0 2
      lib/main.dart
  2. 5 16
      lib/ui/viewer/file/file_widget.dart
  3. 0 21
      lib/utils/device_info.dart
  4. 2 2
      pubspec.lock
  5. 2 2
      pubspec.yaml

+ 0 - 2
lib/main.dart

@@ -43,7 +43,6 @@ import 'package:photos/services/user_service.dart';
 import 'package:photos/ui/tools/app_lock.dart';
 import 'package:photos/ui/tools/lock_screen.dart';
 import 'package:photos/utils/crypto_util.dart';
-import "package:photos/utils/device_info.dart";
 import 'package:photos/utils/file_uploader.dart';
 import 'package:photos/utils/local_settings.dart';
 import 'package:shared_preferences/shared_preferences.dart';
@@ -162,7 +161,6 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
   Computer.shared().turnOn(workersCount: 4, verbose: kDebugMode);
   CryptoUtil.init();
   await NetworkClient.instance.init();
-  initDeviceSpec().ignore();
   await Configuration.instance.init();
   await UserService.instance.init();
   await EntityService.instance.init();

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

@@ -2,10 +2,8 @@ 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;
@@ -40,20 +38,11 @@ class FileWidget extends StatelessWidget {
         key: key ?? ValueKey(fileKey),
       );
     } else if (file.fileType == FileType.video) {
-      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,
-        );
-      }
+      return VideoWidgetNew(
+        file,
+        tagPrefix: tagPrefix,
+        playbackCallback: playbackCallback,
+      );
     } else {
       Logger('FileWidget').severe('unsupported file type ${file.fileType}');
       return const Icon(Icons.error);

+ 0 - 21
lib/utils/device_info.dart

@@ -5,8 +5,6 @@ import 'package:flutter/foundation.dart';
 import 'package:logging/logging.dart';
 
 DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
-bool disableMediaKit = false;
-
 // https://gist.github.com/adamawolf/3048717
 final Set<String> iOSLowEndMachineCodes = <String>{
   "iPhone5,1", //iPhone 5 (GSM)
@@ -31,21 +29,6 @@ final Set<String> iOSLowEndMachineCodes = <String>{
   "iPhone10,5", //  iPhone 8
 };
 
-Future<void> initDeviceSpec() async {
-  if (Platform.isAndroid) {
-    // Note: The current version of media_kit crashes while playing video when
-// hardware malloc is enabled. Users either need to disable the hardware
-// malloc for our app or we need to disable the media_kit for these devices.
-// Currently, we have disabled the media_kit for these devices. and in the
-// future if needed we can add a setting.
-    final androidInfo = await deviceInfoPlugin.androidInfo;
-    disableMediaKit = androidInfo.toString().contains('graphene') ||
-        androidInfo.toString().contains('divest');
-  } else {
-    disableMediaKit = false;
-  }
-}
-
 Future<bool> isLowSpecDevice() async {
   try {
     if (Platform.isIOS) {
@@ -67,7 +50,3 @@ Future<bool> isAndroidSDKVersionLowerThan(int inputSDK) async {
     return false;
   }
 }
-
-bool isCompatibleWithMediaKit() {
-  return disableMediaKit == false;
-}

+ 2 - 2
pubspec.lock

@@ -1155,10 +1155,10 @@ packages:
     dependency: "direct main"
     description:
       name: media_kit
-      sha256: "1283b500341d41f033478706204a2b4ae2612e9b331c934bc4fad8c4bb869f6d"
+      sha256: "3dffc6d0c19117d51fbc42a7f89612e0595665800a596289ab7a80bdd93e0ad1"
       url: "https://pub.dev"
     source: hosted
-    version: "1.1.8+2"
+    version: "1.1.9"
   media_kit_libs_android_video:
     dependency: transitive
     description:

+ 2 - 2
pubspec.yaml

@@ -12,7 +12,7 @@ description: ente photos application
 # Read more about iOS versioning at
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 
-version: 0.7.101+501
+version: 0.7.102+502
 
 environment:
   sdk: ">=3.0.0 <4.0.0"
@@ -95,7 +95,7 @@ dependencies:
   logging: ^1.0.1
   lottie: ^1.2.2
   media_extension: ^1.0.1
-  media_kit: ^1.1.8    
+  media_kit: ^1.1.9
   media_kit_libs_video: ^1.0.3                                  
   media_kit_video: ^1.2.1                    
   modal_bottom_sheet: ^3.0.0-pre