mirror of
https://github.com/DmcSDK/cordova-plugin-mediaPicker
synced 2026-05-22 00:01:31 +08:00
fix ios icloud file download
This commit is contained in:
+1
-1
@@ -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
@@ -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;
|
||||
|
||||
@@ -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]);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user