fix video play button

This commit is contained in:
Danmei Chen 2019-01-14 12:14:18 +01:00
parent 3bc738431f
commit 04169647c2
3 changed files with 17 additions and 9 deletions

View file

@ -1056,7 +1056,7 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog
return FALSE;
}
if ([fileManager isUbiquitousItemAtURL:fileURL]) {
if ([fileManager fileExistsAtPath:[fileURL path]]) {
// if it exists, replace the file
return [data writeToURL:fileURL atomically:TRUE];
} else {
@ -1068,7 +1068,12 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog
}
NSError *error;
return [[NSFileManager defaultManager] setUbiquitous:YES itemAtURL:localURL destinationURL:fileURL error:&error];
if ([[NSFileManager defaultManager] setUbiquitous:YES itemAtURL:localURL destinationURL:fileURL error:&error]) {
return TRUE;
} else {
LOGE(@"Cannot write file in Icloud file [%@]",[error localizedDescription]);
return FALSE;
}
}
}

View file

@ -165,7 +165,9 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100;
NSString *localFile = [LinphoneManager getMessageAppDataForKey:@"localfile" inMessage:self.message];
BOOL fullScreenImage = NO;
assert(is_external || localImage || localVideo || localFile);
NSString *type = [NSString stringWithUTF8String:linphone_chat_message_get_content_type(self.message)];
LinphoneContent *fileContent = linphone_chat_message_get_file_transfer_information(self.message);
NSString *type = fileContent ? [NSString stringWithUTF8String:linphone_content_get_type(fileContent)] : nil;
if (!(localImage || localVideo || localFile)) {
_playButton.hidden = YES;
@ -194,7 +196,7 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100;
}
}
else if (localFile) {
if ([type isEqualToString:@"video/"]) {
if ([type isEqualToString:@"video"]) {
UIImage* image = [UIChatBubbleTextCell getImageFromVideoUrl:[VIEW(ChatConversationView) getICloudFileUrl:localFile]];
[self loadImageAsset:nil image:image];
_imageGestureRecognizer.enabled = YES;
@ -220,7 +222,7 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100;
} else {
_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = YES;
fullScreenImage = YES;
_playButton.hidden = ![type isEqualToString:@"video/"];
_playButton.hidden = ![type isEqualToString:@"video"];
_fileName.hidden = _fileView.hidden = _fileButton.hidden = localFile ? NO : YES;
// Should fix cell not resizing after doanloading image.
[self layoutSubviews];

View file

@ -440,8 +440,9 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100;
size.height = MAX(size.height + CELL_MESSAGE_Y_MARGIN + 50, CELL_MIN_HEIGHT);
return size;
}
if (url == nil && linphone_chat_message_get_file_transfer_information(chat) == NULL) {
LinphoneContent *fileContent = linphone_chat_message_get_file_transfer_information(chat);
if (url == nil && fileContent == NULL) {
size = [self computeBoundingBox:messageText
size:CGSizeMake(width - CELL_MESSAGE_X_MARGIN - 4, CGFLOAT_MAX)
font:messageFont];
@ -460,8 +461,8 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100;
if(localFile) {
UIImage *image = nil;
NSString *type = [NSString stringWithUTF8String:linphone_chat_message_get_content_type(chat)];
if ([type isEqualToString:@"video/"]) {
NSString *type = [NSString stringWithUTF8String:linphone_content_get_type(fileContent)];
if ([type isEqualToString:@"video"]) {
image = [self getImageFromVideoUrl:[VIEW(ChatConversationView) getICloudFileUrl:localFile]];
} else if ([localFile hasSuffix:@"JPG"] || [localFile hasSuffix:@"PNG"] || [localFile hasSuffix:@"jpg"] || [localFile hasSuffix:@"png"]) {
NSData *data = [NSData dataWithContentsOfURL:[VIEW(ChatConversationView) getICloudFileUrl:localFile]];