iOS13获取本地视频的路径:
file:///private/var/mobile/Containers/Data/PluginKitPlugin/43792FA5-A8F8-4ECA-8CCE-0C5877088858/tmp/trim.7F9B8FC4-3307-4452-9F96-46A5D9A9DDD5.MOV
比iOS12多了一个 PluginKitPlugin 的文件夹,导致文件访问受限。
解决方法:
找到 CDVCamera.m 文件
in CDVCamera.m change THIS:
(CDVPluginResult*)resultForVideo:(NSDictionary*)info
{
NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] absoluteString];
return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:filePath];
}
to THIS:
(CDVPluginResult*)resultForVideo:(NSDictionary*)info
{
NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
NSArray* spliteArray = [moviePath componentsSeparatedByString: @"/"];
NSString* lastString = [spliteArray lastObject];
NSError *error;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"tmp"];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:lastString];
[fileManager copyItemAtPath:moviePath toPath:filePath error:&error];
return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:filePath];
}
Mark一下,附上问题答案地址:https://github.com/apache/cordova-plugin-camera/issues/506