set default image for video

This commit is contained in:
Danmei Chen 2018-07-15 19:10:01 +02:00
parent 8ccc66b149
commit 9f0689f297
2 changed files with 25 additions and 26 deletions

View file

@ -181,34 +181,12 @@
if (localImage) {
// we did not load the image yet, so start doing so
if (_messageImageView.image == nil) {
[_messageImageView startLoading];
PHFetchResult<PHAsset *> *assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localImage] options:nil];
UIImage *img = nil;
img = [chatTableView.imagesInChatroom objectForKey:localImage];
if (![assets firstObject])
[self loadPlaceholder];
PHAsset *asset = [assets firstObject];
if (img)
[self loadImageAsset:asset image:img];
else
[self loadAsset:asset];
[self loadFirstImage:localImage type:PHAssetMediaTypeImage];
}
}
else if (localVideo) {
if (_messageImageView.image == nil) {
[_messageImageView startLoading];
PHFetchResult<PHAsset *> *assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localVideo] options:nil];
UIImage *img = nil;
img = [chatTableView.imagesInChatroom objectForKey:localVideo];
if (![assets firstObject])
[self loadPlaceholder];
PHAsset *asset = [assets firstObject];
if (img)
[self loadImageAsset:asset image:img];
else
[self loadAsset:asset];
[self loadFirstImage:localVideo type:PHAssetMediaTypeVideo];
}
}
else if (localFile) {
@ -236,8 +214,25 @@
}
}
- (void)loadFirstImage:(NSString *)key type:(PHAssetMediaType)type {
[_messageImageView startLoading];
PHFetchResult<PHAsset *> *assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:key] options:nil];
UIImage *img = nil;
img = [chatTableView.imagesInChatroom objectForKey:key];
PHAsset *asset = [assets firstObject];
if (!asset)
[self loadPlaceholder];
else if (asset.mediaType == type)
img = nil;
if (img)
[self loadImageAsset:asset image:img];
else
[self loadAsset:asset];
}
- (void)fileErrorBlock {
DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Can't open this file", nil)];
DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Can't find this file", nil)];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[sheet addCancelButtonWithTitle:NSLocalizedString(@"OK", nil) block:nil];
dispatch_async(dispatch_get_main_queue(), ^{

View file

@ -270,6 +270,7 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
linphone_iphone_file_transfer_send);
// internal url is saved in the appdata for display and later save
LOGE(@"nnnn %@ %@",key, keyData);
[LinphoneManager setValueInMessageAppData:keyData forKey:key inMessage:_message];
[LinphoneManager setValueInMessageAppData:qualityData forKey:@"uploadQuality" inMessage:_message];
@ -291,7 +292,10 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
- (void)uploadVideo:(NSData *)data withassetId:(NSString *)phAssetId forChatRoom:(LinphoneChatRoom *)chatRoom {
NSString *name = [NSString stringWithFormat:@"IMG-%f.MOV", [NSDate timeIntervalSinceReferenceDate]];
[self uploadData:data forChatRoom:chatRoom type:@"video" subtype:nil name:name key:@"localvideo" keyData:phAssetId qualityData:nil];
if (phAssetId)
[self uploadData:data forChatRoom:chatRoom type:@"video" subtype:nil name:name key:@"localvideo" keyData:phAssetId qualityData:nil];
else
[self uploadData:data forChatRoom:chatRoom type:@"video" subtype:nil name:name key:@"localvideo" keyData:@"ending..." qualityData:nil];
}
- (void)uploadFile:(NSData *)data forChatRoom:(LinphoneChatRoom *)chatRoom withName:(NSString *)name {