我正在开发一个颤振演示应用程序。我想在手机存储中使用有关视频的元数据。我能够提取该视频的路径,但不知道如何在 dart/flutter 中提取其元数据。
我需要以下元数据:
Maz*_*him 20
您可以使用VideoPlayerController.file
官方视频播放器插件(由官方谷歌团队维护,因此您不必担心其未来和稳定性)中的构造函数来访问该文件并在安装包后获得以下元数据:
首先这是你的VideoPlayerController
:
VideoPlayerController controller = new VideoPlayerController.file('');//Your file here
Run Code Online (Sandbox Code Playgroud)
期间:
controller.value.duration ;
Run Code Online (Sandbox Code Playgroud)视频名称,您应该已经拥有它,因为您可以访问文件路径并将其传递给播放器构造函数。
3.视频大小:
controller.value.size ;
Run Code Online (Sandbox Code Playgroud)
4.至于视频是什么时候拍摄的,我不能帮你。你必须找到另一种方法来解决它。
在 FLutter 中获取视频创建时间的方法之一是使用flutter_ffmpeg插件。
将其添加到pubspec.yaml
:
dependencies:
flutter_ffmpeg: ^0.3.0
Run Code Online (Sandbox Code Playgroud)
获取视频的文件路径,例如使用file_picker:
File pickedFile = await FilePicker.getFile();
Run Code Online (Sandbox Code Playgroud)
使用 ffmpeg 按路径获取视频的元数据:
final FlutterFFprobe flutterFFprobe = FlutterFFprobe();
MediaInformation mediaInformation = await flutterFFprobe.getMediaInformation(pickedFile.path);
Map<dynamic, dynamic> mp = mediaInformation.getMediaProperties();
String creationTime = mp["tags"]["creation_time"];
print("creationTime: $creationTime");
Run Code Online (Sandbox Code Playgroud)
在控制台中你会得到这样的信息:
I/flutter (13274): creationTime: 2020-09-24T17:59:24.000000Z
注意:将此插件添加到您的应用程序中会增加最终 apk 的重量!
归档时间: |
|
查看次数: |
6708 次 |
最近记录: |