Commit a1e3989d authored by DanmeiChen's avatar DanmeiChen
Browse files

fix compability of display files with previous versions

parent d88641c3
Pipeline #29312 passed with stage
in 4 minutes and 51 seconds
......@@ -331,48 +331,13 @@
if (_messageImageView.image == nil) {
[self loadFirstImage:localImage type:PHAssetMediaTypeImage];
_imageGestureRecognizer.enabled = YES;
dispatch_async(dispatch_get_main_queue(), ^ {
UIImage *image = [chatTableView.imagesInChatroom objectForKey:localImage];
NSString *name = [NSString stringWithFormat:@"%li-%f.jpg", (long)image.hash, [NSDate timeIntervalSinceReferenceDate]];
NSData *data = UIImageJPEGRepresentation(image, 1);
[ChatConversationView writeFileInCache:data name:name];
[LinphoneManager setValueInMessageAppData:name forKey:@"localimage" inMessage:self.message];
});
}
} else if (localVideo) {
if (_messageImageView.image == nil) {
[self loadFirstImage:localVideo type:PHAssetMediaTypeVideo];
_imageGestureRecognizer.enabled = NO;
dispatch_async(dispatch_get_main_queue(), ^ {
PHFetchResult<PHAsset *> *assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localVideo] options:nil];
if (![assets firstObject])
return;
PHAsset *asset = [assets firstObject];
if (asset.mediaType != PHAssetMediaTypeVideo)
return;
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
options.version = PHImageRequestOptionsVersionCurrent;
options.deliveryMode = PHVideoRequestOptionsDeliveryModeAutomatic;
[[PHImageManager defaultManager] requestAVAssetForVideo:asset options:options resultHandler:^(AVAsset * _Nullable asset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
AVURLAsset *urlAsset = (AVURLAsset *)asset;
NSData *data = [NSData dataWithContentsOfURL:urlAsset.URL];
NSString *name = [NSString stringWithFormat:@"IMG-%f.MOV", [NSDate timeIntervalSinceReferenceDate]];
[ChatConversationView writeFileInCache:data name:name];
[LinphoneManager setValueInMessageAppData:name forKey:@"localvideo" inMessage:self.message];
}];
});
}
} else if (localFile) {
dispatch_async(dispatch_get_main_queue(), ^ {
NSURL *url = [VIEW(ChatConversationView) getICloudFileUrl:localFile];
NSData *data = [NSData dataWithContentsOfURL:url];
[ChatConversationView writeFileInCache:data name:localFile];
});
if ([fileType isEqualToString:@"video"]) {
UIImage* image = [UIChatBubbleTextCell getImageFromVideoUrl:[VIEW(ChatConversationView) getICloudFileUrl:localFile]];
[self loadImageAsset:nil image:image];
......@@ -472,11 +437,6 @@
NSURL *url = [VIEW(ChatConversationView) getICloudFileUrl:localFile];
AVPlayer *player = [AVPlayer playerWithURL:url];
[self playVideoByPlayer:player];
dispatch_async(dispatch_get_main_queue(), ^ {
NSData *data = [NSData dataWithContentsOfURL:url];
[ChatConversationView writeFileInCache:data name:localFile];
});
return;
}
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment