【发布时间】:2021-04-02 23:37:18
【问题描述】:
请问,有谁能帮我理解为什么在 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>
在 Podfile 中,我也有这个:
目标“跑步者”做 使用_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(() {});
}
感谢您的帮助。
【问题讨论】:
-
allowedExtensions: ['mp4', 'jpg'],你试过这个吗?
-
@ShubhamNarkhede 我实际上不想这样做,因为我有另一种方法来选择特定的图像格式......但谢谢。
标签: flutter flutter-dependencies