Forráskód Böngészése

Fix video playback (#1301)

Ashil 2 éve
szülő
commit
b8bdc1fe60

+ 2 - 0
lib/generated/intl/messages_cs.dart

@@ -24,6 +24,8 @@ class MessageLookup extends MessageLookupByLibrary {
   static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
   static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
         "deleteReason2": MessageLookupByLibrary.simpleMessage(
         "deleteReason2": MessageLookupByLibrary.simpleMessage(
             "The app or a certain feature does not behave as I think it should"),
             "The app or a certain feature does not behave as I think it should"),
+        "failedToDownloadVideo":
+            MessageLookupByLibrary.simpleMessage("Failed to download video"),
         "inviteYourFriendsToEnte":
         "inviteYourFriendsToEnte":
             MessageLookupByLibrary.simpleMessage("Invite your friends to ente"),
             MessageLookupByLibrary.simpleMessage("Invite your friends to ente"),
         "noAlbumsSharedByYouYet":
         "noAlbumsSharedByYouYet":

+ 2 - 0
lib/generated/intl/messages_de.dart

@@ -627,6 +627,8 @@ class MessageLookup extends MessageLookupByLibrary {
             "Der Code konnte nicht aktiviert werden"),
             "Der Code konnte nicht aktiviert werden"),
         "failedToCancel":
         "failedToCancel":
             MessageLookupByLibrary.simpleMessage("Kündigung fehlgeschlagen"),
             MessageLookupByLibrary.simpleMessage("Kündigung fehlgeschlagen"),
+        "failedToDownloadVideo":
+            MessageLookupByLibrary.simpleMessage("Failed to download video"),
         "failedToFetchOriginalForEdit": MessageLookupByLibrary.simpleMessage(
         "failedToFetchOriginalForEdit": MessageLookupByLibrary.simpleMessage(
             "Fehler beim Abrufen des Originals zur Bearbeitung"),
             "Fehler beim Abrufen des Originals zur Bearbeitung"),
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(

+ 2 - 0
lib/generated/intl/messages_en.dart

@@ -628,6 +628,8 @@ class MessageLookup extends MessageLookupByLibrary {
             MessageLookupByLibrary.simpleMessage("Failed to apply code"),
             MessageLookupByLibrary.simpleMessage("Failed to apply code"),
         "failedToCancel":
         "failedToCancel":
             MessageLookupByLibrary.simpleMessage("Failed to cancel"),
             MessageLookupByLibrary.simpleMessage("Failed to cancel"),
+        "failedToDownloadVideo":
+            MessageLookupByLibrary.simpleMessage("Failed to download video"),
         "failedToFetchOriginalForEdit": MessageLookupByLibrary.simpleMessage(
         "failedToFetchOriginalForEdit": MessageLookupByLibrary.simpleMessage(
             "Failed to fetch original for edit"),
             "Failed to fetch original for edit"),
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(

+ 2 - 0
lib/generated/intl/messages_es.dart

@@ -600,6 +600,8 @@ class MessageLookup extends MessageLookupByLibrary {
             MessageLookupByLibrary.simpleMessage("Error al aplicar el código"),
             MessageLookupByLibrary.simpleMessage("Error al aplicar el código"),
         "failedToCancel":
         "failedToCancel":
             MessageLookupByLibrary.simpleMessage("Error al cancelar"),
             MessageLookupByLibrary.simpleMessage("Error al cancelar"),
+        "failedToDownloadVideo":
+            MessageLookupByLibrary.simpleMessage("Failed to download video"),
         "failedToFetchOriginalForEdit": MessageLookupByLibrary.simpleMessage(
         "failedToFetchOriginalForEdit": MessageLookupByLibrary.simpleMessage(
             "No se pudo obtener el original para editar"),
             "No se pudo obtener el original para editar"),
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(

+ 2 - 0
lib/generated/intl/messages_fr.dart

@@ -488,6 +488,8 @@ class MessageLookup extends MessageLookupByLibrary {
             "Impossible d\'appliquer le code"),
             "Impossible d\'appliquer le code"),
         "failedToCancel":
         "failedToCancel":
             MessageLookupByLibrary.simpleMessage("Échec de l\'annulation"),
             MessageLookupByLibrary.simpleMessage("Échec de l\'annulation"),
+        "failedToDownloadVideo":
+            MessageLookupByLibrary.simpleMessage("Failed to download video"),
         "failedToFetchOriginalForEdit": MessageLookupByLibrary.simpleMessage(
         "failedToFetchOriginalForEdit": MessageLookupByLibrary.simpleMessage(
             "Impossible de récupérer l\'original pour l\'édition"),
             "Impossible de récupérer l\'original pour l\'édition"),
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(

+ 2 - 0
lib/generated/intl/messages_it.dart

@@ -635,6 +635,8 @@ class MessageLookup extends MessageLookupByLibrary {
             "Impossibile applicare il codice"),
             "Impossibile applicare il codice"),
         "failedToCancel":
         "failedToCancel":
             MessageLookupByLibrary.simpleMessage("Impossibile annullare"),
             MessageLookupByLibrary.simpleMessage("Impossibile annullare"),
+        "failedToDownloadVideo":
+            MessageLookupByLibrary.simpleMessage("Failed to download video"),
         "failedToFetchOriginalForEdit": MessageLookupByLibrary.simpleMessage(
         "failedToFetchOriginalForEdit": MessageLookupByLibrary.simpleMessage(
             "Impossibile recuperare l\'originale per la modifica"),
             "Impossibile recuperare l\'originale per la modifica"),
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(

+ 2 - 0
lib/generated/intl/messages_ko.dart

@@ -24,6 +24,8 @@ class MessageLookup extends MessageLookupByLibrary {
   static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
   static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
         "deleteReason2": MessageLookupByLibrary.simpleMessage(
         "deleteReason2": MessageLookupByLibrary.simpleMessage(
             "The app or a certain feature does not behave as I think it should"),
             "The app or a certain feature does not behave as I think it should"),
+        "failedToDownloadVideo":
+            MessageLookupByLibrary.simpleMessage("Failed to download video"),
         "inviteYourFriendsToEnte":
         "inviteYourFriendsToEnte":
             MessageLookupByLibrary.simpleMessage("Invite your friends to ente"),
             MessageLookupByLibrary.simpleMessage("Invite your friends to ente"),
         "noAlbumsSharedByYouYet":
         "noAlbumsSharedByYouYet":

+ 2 - 0
lib/generated/intl/messages_nl.dart

@@ -624,6 +624,8 @@ class MessageLookup extends MessageLookupByLibrary {
             MessageLookupByLibrary.simpleMessage("Code toepassen mislukt"),
             MessageLookupByLibrary.simpleMessage("Code toepassen mislukt"),
         "failedToCancel":
         "failedToCancel":
             MessageLookupByLibrary.simpleMessage("Opzeggen mislukt"),
             MessageLookupByLibrary.simpleMessage("Opzeggen mislukt"),
+        "failedToDownloadVideo":
+            MessageLookupByLibrary.simpleMessage("Failed to download video"),
         "failedToFetchOriginalForEdit": MessageLookupByLibrary.simpleMessage(
         "failedToFetchOriginalForEdit": MessageLookupByLibrary.simpleMessage(
             "Fout bij ophalen origineel voor bewerking"),
             "Fout bij ophalen origineel voor bewerking"),
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(

+ 2 - 0
lib/generated/intl/messages_no.dart

@@ -41,6 +41,8 @@ class MessageLookup extends MessageLookupByLibrary {
             "Vennligst skriv inn en gyldig e-postadresse."),
             "Vennligst skriv inn en gyldig e-postadresse."),
         "enterYourEmailAddress": MessageLookupByLibrary.simpleMessage(
         "enterYourEmailAddress": MessageLookupByLibrary.simpleMessage(
             "Skriv inn e-postadressen din"),
             "Skriv inn e-postadressen din"),
+        "failedToDownloadVideo":
+            MessageLookupByLibrary.simpleMessage("Failed to download video"),
         "feedback": MessageLookupByLibrary.simpleMessage("Tilbakemelding"),
         "feedback": MessageLookupByLibrary.simpleMessage("Tilbakemelding"),
         "invalidEmailAddress":
         "invalidEmailAddress":
             MessageLookupByLibrary.simpleMessage("Ugyldig e-postadresse"),
             MessageLookupByLibrary.simpleMessage("Ugyldig e-postadresse"),

+ 2 - 0
lib/generated/intl/messages_pl.dart

@@ -89,6 +89,8 @@ class MessageLookup extends MessageLookupByLibrary {
             MessageLookupByLibrary.simpleMessage("Wprowadź hasło"),
             MessageLookupByLibrary.simpleMessage("Wprowadź hasło"),
         "enterYourRecoveryKey": MessageLookupByLibrary.simpleMessage(
         "enterYourRecoveryKey": MessageLookupByLibrary.simpleMessage(
             "Wprowadź swój klucz odzyskiwania"),
             "Wprowadź swój klucz odzyskiwania"),
+        "failedToDownloadVideo":
+            MessageLookupByLibrary.simpleMessage("Failed to download video"),
         "feedback": MessageLookupByLibrary.simpleMessage("Informacja zwrotna"),
         "feedback": MessageLookupByLibrary.simpleMessage("Informacja zwrotna"),
         "forgotPassword":
         "forgotPassword":
             MessageLookupByLibrary.simpleMessage("Nie pamiętam hasła"),
             MessageLookupByLibrary.simpleMessage("Nie pamiętam hasła"),

+ 2 - 0
lib/generated/intl/messages_pt.dart

@@ -207,6 +207,8 @@ class MessageLookup extends MessageLookupByLibrary {
             "Digite sua chave de recuperação"),
             "Digite sua chave de recuperação"),
         "exportYourData":
         "exportYourData":
             MessageLookupByLibrary.simpleMessage("Exportar seus dados"),
             MessageLookupByLibrary.simpleMessage("Exportar seus dados"),
+        "failedToDownloadVideo":
+            MessageLookupByLibrary.simpleMessage("Failed to download video"),
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(
         "failedToFetchReferralDetails": MessageLookupByLibrary.simpleMessage(
             "Não foi possível buscar informações do produto. Por favor, tente novamente mais tarde."),
             "Não foi possível buscar informações do produto. Por favor, tente novamente mais tarde."),
         "faq": MessageLookupByLibrary.simpleMessage("Perguntas frequentes"),
         "faq": MessageLookupByLibrary.simpleMessage("Perguntas frequentes"),

+ 2 - 0
lib/generated/intl/messages_zh.dart

@@ -509,6 +509,8 @@ class MessageLookup extends MessageLookupByLibrary {
         "exportYourData": MessageLookupByLibrary.simpleMessage("导出您的数据"),
         "exportYourData": MessageLookupByLibrary.simpleMessage("导出您的数据"),
         "failedToApplyCode": MessageLookupByLibrary.simpleMessage("无法应用代码"),
         "failedToApplyCode": MessageLookupByLibrary.simpleMessage("无法应用代码"),
         "failedToCancel": MessageLookupByLibrary.simpleMessage("取消失败"),
         "failedToCancel": MessageLookupByLibrary.simpleMessage("取消失败"),
+        "failedToDownloadVideo":
+            MessageLookupByLibrary.simpleMessage("Failed to download video"),
         "failedToFetchOriginalForEdit":
         "failedToFetchOriginalForEdit":
             MessageLookupByLibrary.simpleMessage("无法获取原始编辑"),
             MessageLookupByLibrary.simpleMessage("无法获取原始编辑"),
         "failedToFetchReferralDetails":
         "failedToFetchReferralDetails":

+ 10 - 0
lib/generated/l10n.dart

@@ -7574,6 +7574,16 @@ class S {
       args: [],
       args: [],
     );
     );
   }
   }
+
+  /// `Failed to download video`
+  String get failedToDownloadVideo {
+    return Intl.message(
+      'Failed to download video',
+      name: 'failedToDownloadVideo',
+      desc: '',
+      args: [],
+    );
+  }
 }
 }
 
 
 class AppLocalizationDelegate extends LocalizationsDelegate<S> {
 class AppLocalizationDelegate extends LocalizationsDelegate<S> {

+ 2 - 1
lib/l10n/intl_cs.arb

@@ -5,5 +5,6 @@
   "sharedWithYou": "Shared with you",
   "sharedWithYou": "Shared with you",
   "sharedByYou": "Shared by you",
   "sharedByYou": "Shared by you",
   "inviteYourFriendsToEnte": "Invite your friends to ente",
   "inviteYourFriendsToEnte": "Invite your friends to ente",
-  "deleteReason2": "The app or a certain feature does not behave as I think it should"
+  "deleteReason2": "The app or a certain feature does not behave as I think it should",
+  "failedToDownloadVideo": "Failed to download video"
 }
 }

+ 2 - 1
lib/l10n/intl_de.arb

@@ -1062,5 +1062,6 @@
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "sharedWithYou": "Shared with you",
   "sharedWithYou": "Shared with you",
   "sharedByYou": "Shared by you",
   "sharedByYou": "Shared by you",
-  "inviteYourFriendsToEnte": "Invite your friends to ente"
+  "inviteYourFriendsToEnte": "Invite your friends to ente",
+  "failedToDownloadVideo": "Failed to download video"
 }
 }

+ 4 - 3
lib/l10n/intl_en.arb

@@ -979,7 +979,7 @@
   "centerPoint": "Center point",
   "centerPoint": "Center point",
   "pickCenterPoint": "Pick center point",
   "pickCenterPoint": "Pick center point",
   "useSelectedPhoto": "Use selected photo",
   "useSelectedPhoto": "Use selected photo",
-  "resetToDefault" : "Reset to default",
+  "resetToDefault": "Reset to default",
   "@resetToDefault": {
   "@resetToDefault": {
     "description": "Button text to reset cover photo to default"
     "description": "Button text to reset cover photo to default"
   },
   },
@@ -1102,5 +1102,6 @@
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "sharedWithYou": "Shared with you",
   "sharedWithYou": "Shared with you",
   "sharedByYou": "Shared by you",
   "sharedByYou": "Shared by you",
-  "inviteYourFriendsToEnte": "Invite your friends to ente"
-}
+  "inviteYourFriendsToEnte": "Invite your friends to ente",
+  "failedToDownloadVideo": "Failed to download video"
+}

+ 2 - 1
lib/l10n/intl_es.arb

@@ -977,5 +977,6 @@
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "sharedWithYou": "Shared with you",
   "sharedWithYou": "Shared with you",
   "sharedByYou": "Shared by you",
   "sharedByYou": "Shared by you",
-  "inviteYourFriendsToEnte": "Invite your friends to ente"
+  "inviteYourFriendsToEnte": "Invite your friends to ente",
+  "failedToDownloadVideo": "Failed to download video"
 }
 }

+ 2 - 1
lib/l10n/intl_fr.arb

@@ -732,5 +732,6 @@
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "sharedWithYou": "Shared with you",
   "sharedWithYou": "Shared with you",
   "sharedByYou": "Shared by you",
   "sharedByYou": "Shared by you",
-  "inviteYourFriendsToEnte": "Invite your friends to ente"
+  "inviteYourFriendsToEnte": "Invite your friends to ente",
+  "failedToDownloadVideo": "Failed to download video"
 }
 }

+ 2 - 1
lib/l10n/intl_it.arb

@@ -1085,5 +1085,6 @@
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "sharedWithYou": "Shared with you",
   "sharedWithYou": "Shared with you",
   "sharedByYou": "Shared by you",
   "sharedByYou": "Shared by you",
-  "inviteYourFriendsToEnte": "Invite your friends to ente"
+  "inviteYourFriendsToEnte": "Invite your friends to ente",
+  "failedToDownloadVideo": "Failed to download video"
 }
 }

+ 2 - 1
lib/l10n/intl_ko.arb

@@ -5,5 +5,6 @@
   "sharedWithYou": "Shared with you",
   "sharedWithYou": "Shared with you",
   "sharedByYou": "Shared by you",
   "sharedByYou": "Shared by you",
   "inviteYourFriendsToEnte": "Invite your friends to ente",
   "inviteYourFriendsToEnte": "Invite your friends to ente",
-  "deleteReason2": "The app or a certain feature does not behave as I think it should"
+  "deleteReason2": "The app or a certain feature does not behave as I think it should",
+  "failedToDownloadVideo": "Failed to download video"
 }
 }

+ 2 - 1
lib/l10n/intl_nl.arb

@@ -1049,5 +1049,6 @@
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "sharedWithYou": "Shared with you",
   "sharedWithYou": "Shared with you",
   "sharedByYou": "Shared by you",
   "sharedByYou": "Shared by you",
-  "inviteYourFriendsToEnte": "Invite your friends to ente"
+  "inviteYourFriendsToEnte": "Invite your friends to ente",
+  "failedToDownloadVideo": "Failed to download video"
 }
 }

+ 2 - 1
lib/l10n/intl_no.arb

@@ -19,5 +19,6 @@
   "sharedWithYou": "Shared with you",
   "sharedWithYou": "Shared with you",
   "sharedByYou": "Shared by you",
   "sharedByYou": "Shared by you",
   "inviteYourFriendsToEnte": "Invite your friends to ente",
   "inviteYourFriendsToEnte": "Invite your friends to ente",
-  "deleteReason2": "The app or a certain feature does not behave as I think it should"
+  "deleteReason2": "The app or a certain feature does not behave as I think it should",
+  "failedToDownloadVideo": "Failed to download video"
 }
 }

+ 2 - 1
lib/l10n/intl_pl.arb

@@ -106,5 +106,6 @@
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "sharedWithYou": "Shared with you",
   "sharedWithYou": "Shared with you",
   "sharedByYou": "Shared by you",
   "sharedByYou": "Shared by you",
-  "inviteYourFriendsToEnte": "Invite your friends to ente"
+  "inviteYourFriendsToEnte": "Invite your friends to ente",
+  "failedToDownloadVideo": "Failed to download video"
 }
 }

+ 2 - 1
lib/l10n/intl_pt.arb

@@ -272,5 +272,6 @@
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "sharedWithYou": "Shared with you",
   "sharedWithYou": "Shared with you",
   "sharedByYou": "Shared by you",
   "sharedByYou": "Shared by you",
-  "inviteYourFriendsToEnte": "Invite your friends to ente"
+  "inviteYourFriendsToEnte": "Invite your friends to ente",
+  "failedToDownloadVideo": "Failed to download video"
 }
 }

+ 2 - 1
lib/l10n/intl_zh.arb

@@ -1047,5 +1047,6 @@
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "noAlbumsSharedByYouYet": "No albums shared by you yet",
   "sharedWithYou": "Shared with you",
   "sharedWithYou": "Shared with you",
   "sharedByYou": "Shared by you",
   "sharedByYou": "Shared by you",
-  "inviteYourFriendsToEnte": "Invite your friends to ente"
+  "inviteYourFriendsToEnte": "Invite your friends to ente",
+  "failedToDownloadVideo": "Failed to download video"
 }
 }

+ 24 - 19
lib/ui/viewer/file/video_widget.dart

@@ -42,7 +42,7 @@ class _VideoWidgetState extends State<VideoWidget> {
   final _logger = Logger("VideoWidget");
   final _logger = Logger("VideoWidget");
   VideoPlayerController? _videoPlayerController;
   VideoPlayerController? _videoPlayerController;
   ChewieController? _chewieController;
   ChewieController? _chewieController;
-  double? _progress;
+  final _progressNotifier = ValueNotifier<double?>(null);
   bool _isPlaying = false;
   bool _isPlaying = false;
   bool _wakeLockEnabledHere = false;
   bool _wakeLockEnabledHere = false;
 
 
@@ -93,19 +93,19 @@ class _VideoWidgetState extends State<VideoWidget> {
     getFileFromServer(
     getFileFromServer(
       widget.file,
       widget.file,
       progressCallback: (count, total) {
       progressCallback: (count, total) {
-        if (mounted) {
-          setState(() {
-            _progress = count / (widget.file.fileSize ?? total);
-            if (_progress == 1) {
-              showShortToast(context, S.of(context).decryptingVideo);
-            }
-          });
+        _progressNotifier.value = count / (widget.file.fileSize ?? total);
+        if (_progressNotifier.value == 1) {
+          if (mounted) {
+            showShortToast(context, S.of(context).decryptingVideo);
+          }
         }
         }
       },
       },
     ).then((file) {
     ).then((file) {
       if (file != null) {
       if (file != null) {
         _setVideoPlayerController(file: file);
         _setVideoPlayerController(file: file);
       }
       }
+    }).onError((error, stackTrace) {
+      showErrorDialog(context, "Error", S.of(context).failedToDownloadVideo);
     });
     });
   }
   }
 
 
@@ -198,17 +198,22 @@ class _VideoWidgetState extends State<VideoWidget> {
         Center(
         Center(
           child: SizedBox.fromSize(
           child: SizedBox.fromSize(
             size: const Size.square(20),
             size: const Size.square(20),
-            child: _progress == null || _progress == 1
-                ? const CupertinoActivityIndicator(
-                    color: Colors.white,
-                  )
-                : CircularProgressIndicator(
-                    backgroundColor: Colors.black,
-                    value: _progress,
-                    valueColor: const AlwaysStoppedAnimation<Color>(
-                      Color.fromRGBO(45, 194, 98, 1.0),
-                    ),
-                  ),
+            child: ValueListenableBuilder(
+              valueListenable: _progressNotifier,
+              builder: (BuildContext context, double? progress, _) {
+                return progress == null || progress == 1
+                    ? const CupertinoActivityIndicator(
+                        color: Colors.white,
+                      )
+                    : CircularProgressIndicator(
+                        backgroundColor: Colors.black,
+                        value: progress,
+                        valueColor: const AlwaysStoppedAnimation<Color>(
+                          Color.fromRGBO(45, 194, 98, 1.0),
+                        ),
+                      );
+              },
+            ),
           ),
           ),
         ),
         ),
       ],
       ],