gpt4 book ai didi

flutter - Flutter imagepicker.pickvideo返回jpg

转载 作者:行者123 更新时间:2023-12-03 03:19:41 25 4
gpt4 key购买 nike

我正在用它来返回视频文件,但是我得到了.jpg

Future<File> getVideo() async {
var video = await ImagePicker.pickVideo(
source: ImageSource.gallery);
return video;
}
我想 ImagePicker.pickVideo()返回视频文件而不是.jpg文件,以便可以将此文件上传到Firebase,如何实现?

最佳答案

我假设您正在使用该软件包:
https://pub.dev/packages/image_picker
pickVideo()方法已弃用,您需要将这些API替换为 getVideo()
如存储库文档所述:
https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker
这样写:

final _picker = ImagePicker();
PickedFile video = await _picker.getVideo(...)
但是我建议使用此软件包作为替代:
https://pub.dev/packages/flutter_document_picker
该软件包可让您选择设备上的所有视频,包括从用户的Google云端硬盘或iCloud提供商处拍摄的视频。在这种情况下,请写下:
FlutterDocumentPickerParams params = FlutterDocumentPickerParams(
allowedUtiTypes: [
'public.video',
'public.mpeg',
'public.mpeg-4-audio',
'com.apple.protected-​mpeg-4-audio'
],
allowedMimeTypes: [
'video/mpeg',
'video/x-flv',
'video/mp4',
'application/x-mpegURL',
'video/quicktime',
'video/x-msvideo',
'video/x-ms-wmv',
'video/ogg',
'video/mp2t',
'video/3gpp'
],
invalidFileNameSymbols: ['/'],
);

return await FlutterDocumentPicker.openDocument(params: params);
您需要确保正确设置iOS和Android视频的Mimes和Uti类型。

关于flutter - Flutter imagepicker.pickvideo返回jpg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64384815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com