瀏覽代碼

video duration for remote files

ashilkn 3 年之前
父節點
當前提交
f4ef14676f
共有 2 個文件被更改,包括 24 次插入6 次删除
  1. 6 6
      lib/ui/viewer/file/file_info_dialog.dart
  2. 18 0
      lib/utils/date_time_util.dart

+ 6 - 6
lib/ui/viewer/file/file_info_dialog.dart

@@ -67,9 +67,6 @@ class _FileInfoWidgetState extends State<FileInfoWidget> {
         Theme.of(context).colorScheme.onSurface.withOpacity(0.85); //remove
 
     if (_isImage && _exif != null) {
-      // items.add(_getExifWidgets(_exif));
-      print("_isImage");
-      print(_isImage);
       _generateExifForDetails(_exif);
     }
     final bool showExifListTile = _exifData["focalLength"] != null ||
@@ -140,9 +137,7 @@ class _FileInfoWidgetState extends State<FileInfoWidget> {
               padding: const EdgeInsets.only(right: 10),
               child: _getFileSize(),
             ),
-            file.localID != null && !_isImage
-                ? _getVideoDuration()
-                : const SizedBox.shrink(),
+            !_isImage ? _getVideoDuration() : const SizedBox.shrink(),
           ],
         ),
         trailing: file.uploadedFileID == null ||
@@ -702,6 +697,11 @@ class _FileInfoWidgetState extends State<FileInfoWidget> {
   }
 
   Widget _getVideoDuration() {
+    if (widget.file.duration != 0) {
+      return Text(
+        secondsToHHMMSS(widget.file.duration),
+      );
+    }
     return FutureBuilder(
       future: widget.file.getAsset(),
       builder: (context, snapshot) {

+ 18 - 0
lib/utils/date_time_util.dart

@@ -230,3 +230,21 @@ String getDayTitle(int timestamp) {
   }
   return title;
 }
+
+String secondsToHHMMSS(int value) {
+  int h, m, s;
+  h = value ~/ 3600;
+  m = ((value - h * 3600)) ~/ 60;
+  s = value - (h * 3600) - (m * 60);
+  String hourLeft = h.toString().length < 2 ? "0" + h.toString() : h.toString();
+
+  String minuteLeft =
+      m.toString().length < 2 ? "0" + m.toString() : m.toString();
+
+  String secondsLeft =
+      s.toString().length < 2 ? "0" + s.toString() : s.toString();
+
+  String result = "$hourLeft:$minuteLeft:$secondsLeft";
+
+  return result;
+}