Hen*_*nry 1 flutter flutter-dependencies
请问,有人能帮助我理解为什么在 iOS 中我只能访问 iCloud 文件吗?我需要用户能够从设备库访问文件(视频和图像)。我不确定这是否是权限问题,但在 info.plist 文件中我有这个:
<key>NSCameraUsageDescription</key>
<string>Allows you to take a picture</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allows you to record a voice</string>
<key>NSAppleMusicUsageDescription</key>
<string>Allows you to choose a music</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Allows you to choose a picture</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>fetch</string>
<string>processing</string>
<string>remote-notification</string>
</array>
Run Code Online (Sandbox Code Playgroud)
在 Podfile 中,我还有这个:
目标“跑步者”使用 use_frameworks!
下面是我的代码来挑选视频,最多5个文件,一一选择...
List<Files> _selectedFiles = [];
pickVideos() async {
if (_selectedFiles.length >= 5) {
Toast.show(t.maximumallowedsizehint, context);
return;
}
FilePickerResult result = await FilePicker.platform.pickFiles(
type: FileType.custom,
// allowCompression: true,
allowMultiple: true,
withData: false,
allowedExtensions: ['mp4'],
);
if (mounted) {
if (result != null) {
PlatformFile file = result.files.first;
print(file.name);
//print(file.bytes);
print(file.size);
print(file.extension);
print(file.path);
if (file.size > (1024 * 100)) {
Toast.show(t.maximumuploadsizehint, context);
return;
}
final filePath = await FlutterAbsolutePath.getAbsolutePath(file.path);
print("video absolute path " + filePath);
_selectedFiles.add(new Files(
link: filePath,
type: "video",
filetype: file.extension,
length: file.size,
thumbnail: "null"));
//genThumbnailFile(_selectedFiles.length - 1);
}
setState(() {});
}
Run Code Online (Sandbox Code Playgroud)
感谢您的任何帮助。
我已经联系了包裹所有者(Miguel Ruivo),他非常友善地回答我并提供了解决方案。
而不是使用 FileType.custom
FilePickerResult result = await FilePicker.platform.pickFiles(type: FileType.custom);
Run Code Online (Sandbox Code Playgroud)
使用 FileType.media:
FilePickerResult result = await FilePicker.platform.pickFiles(type: FileType.media);
Run Code Online (Sandbox Code Playgroud)
这解决了我的问题!
| 归档时间: |
|
| 查看次数: |
2256 次 |
| 最近记录: |