fix ios icloud file download

This commit is contained in:
yaw
2018-11-07 10:02:24 +08:00
parent ff85329b09
commit 01c116a2fd
5 changed files with 24 additions and 8 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-mediapicker-dmcsdk",
"version": "2.3.9",
"version": "2.4.0",
"description": "android ios mediaPicker support selection of multiple image and video",
"cordova": {
"id": "cordova-plugin-mediapicker-dmcsdk",
@@ -326,7 +326,9 @@
CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identify forIndexPath:indexPath];
[cell sizeToFit];
PHAsset *asset=fetchResult[indexPath.item];
[_manager requestImageForAsset:asset targetSize:CGSizeMake(200 , 200) contentMode:PHImageContentModeAspectFill options:nil
PHImageRequestOptions *option = [[PHImageRequestOptions alloc] init];
option.networkAccessAllowed = YES;
[_manager requestImageForAsset:asset targetSize:CGSizeMake(200 , 200) contentMode:PHImageContentModeAspectFill options:option
resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
BOOL downloadFinined = (![[info objectForKey:PHImageCancelledKey] boolValue] && ![info objectForKey:PHImageErrorKey] && ![[info objectForKey:PHImageResultIsDegradedKey] boolValue]);
if (downloadFinined && result) {
@@ -142,9 +142,9 @@
PHAsset *asset=_preArray[indexPath.item];//访问已释放的对象
PHImageRequestOptions *option = [[PHImageRequestOptions alloc] init];
option.resizeMode = PHImageRequestOptionsResizeModeFast;
option.networkAccessAllowed = YES;
NSString *fileName =[asset valueForKey:@"filename"];
NSString * fileExtension = [fileName pathExtension];
if([@"GIF" caseInsensitiveCompare:fileExtension]){
cell.gifView.hidden=YES;
[[PHImageManager defaultManager] requestImageForAsset:asset targetSize:CGSizeMake(SCREEN_WIDTH*3 , SCREENH_HEIGHT*3) contentMode:PHImageContentModeAspectFill options:option resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
+16 -5
View File
@@ -67,9 +67,14 @@
}
-(void)imageToSandbox:(PHAsset *)asset dmcPickerPath:(NSString*)dmcPickerPath aListArray:(NSMutableArray*)aListArray selectArray:(NSMutableArray*)selectArray index:(int)index{
[[PHImageManager defaultManager] requestImageDataForAsset:asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
options.networkAccessAllowed = YES;
options.resizeMode = PHImageRequestOptionsResizeModeFast;
options.progressHandler = ^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
NSString *compressCompletedjs = [NSString stringWithFormat:@"MediaPicker.icloudDownloadEvent(%f,%i)", progress,index];
[self.commandDelegate evalJs:compressCompletedjs];
};
[[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
NSString *filename=[asset valueForKey:@"filename"];
NSString *fullpath=[NSString stringWithFormat:@"%@/%@%@", dmcPickerPath,[[NSProcessInfo processInfo] globallyUniqueString], filename];
NSNumber *size=[NSNumber numberWithLong:imageData.length];
@@ -112,8 +117,14 @@
-(void)videoToSandbox:(PHAsset *)asset dmcPickerPath:(NSString*)dmcPickerPath aListArray:(NSMutableArray*)aListArray selectArray:(NSMutableArray*)selectArray index:(int)index{
[[PHImageManager defaultManager] requestAVAssetForVideo:asset options:nil resultHandler:^(AVAsset *avsset, AVAudioMix *audioMix, NSDictionary *info) {
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
options.networkAccessAllowed = YES;
options.resizeMode = PHImageRequestOptionsResizeModeFast;
options.progressHandler = ^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
NSString *compressCompletedjs = [NSString stringWithFormat:@"MediaPicker.icloudDownloadEvent(%f,%i)", progress,index];
[self.commandDelegate evalJs:compressCompletedjs];
};
[[PHImageManager defaultManager] requestAVAssetForVideo:asset options:options resultHandler:^(AVAsset *avsset, AVAudioMix *audioMix, NSDictionary *info) {
if ([avsset isKindOfClass:[AVURLAsset class]]) {
NSString *filename = [asset valueForKey:@"filename"];
AVURLAsset* urlAsset = (AVURLAsset*)avsset;
+3
View File
@@ -17,6 +17,9 @@ var MediaPicker = {
compressEvent:function(s,i) {
cordova.fireDocumentEvent('MediaPicker.CompressVideoEvent', {'status':s,'index':i});
},
icloudDownloadEvent:function(p,i) {
cordova.fireDocumentEvent('MediaPicker.icloudDownloadEvent', {'progress':p,'index':i});
},
compressImage:function(arg0, success, error) {
exec(success, error, "MediaPicker", "compressImage", [arg0]);
},