mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-24 06:38:08 +00:00
Fix duration display on mkv voice memos
This commit is contained in:
parent
14f61e3cef
commit
234152a2f9
2 changed files with 8 additions and 15 deletions
|
|
@ -184,7 +184,7 @@
|
|||
_voiceRecordingFile = [NSString stringWithUTF8String:[VFSUtil vfsEnabledWithGroupName:kLinphoneMsgNotificationAppGroupId] ? linphone_content_get_plain_file_path(voiceContent) : linphone_content_get_file_path(voiceContent)];
|
||||
if ([VFSUtil vfsEnabledWithGroupName:kLinphoneMsgNotificationAppGroupId])
|
||||
[encrptedFilePaths setValue:_voiceRecordingFile forKey:[NSString stringWithUTF8String:linphone_content_get_name(voiceContent)]];
|
||||
[self setVoiceMessageDuration];
|
||||
_vrTimerLabel.text = [self formattedDuration:linphone_content_get_file_duration(voiceContent)/1000];
|
||||
_vrWaveMaskPlayback.frame = CGRectZero;
|
||||
_vrWaveMaskPlayback.backgroundColor = linphone_chat_message_is_outgoing(self.message) ? UIColor.orangeColor : UIColor.grayColor;
|
||||
}
|
||||
|
|
@ -755,14 +755,6 @@
|
|||
|
||||
// Voice messages
|
||||
|
||||
static AVAudioPlayer* utilityPlayer;
|
||||
|
||||
-(void) setVoiceMessageDuration {
|
||||
NSError *error = nil;
|
||||
AVAudioPlayer* utilityPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL URLWithString:_voiceRecordingFile] error:&error]; // Workaround as opening multiple linphone_players at the same time can cause crash (here for example layout refreshed whilst a voice memo is playing
|
||||
_vrTimerLabel.text = [self formattedDuration:utilityPlayer.duration];
|
||||
utilityPlayer = nil;
|
||||
}
|
||||
|
||||
-(void) voicePlayTimerUpdate {
|
||||
CGRect r = _vrWaveMaskPlayback.frame;
|
||||
|
|
|
|||
|
|
@ -385,15 +385,16 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
|||
}
|
||||
|
||||
|
||||
+(NSString *)formattedDuration:(long)valueMs {
|
||||
return [NSString stringWithFormat:@"%02ld:%02ld", valueMs/ 60, (valueMs % 60) ];
|
||||
+(NSString *)formattedDuration:(long)valueSec {
|
||||
return [NSString stringWithFormat:@"%02ld:%02ld", valueSec/ 60, (valueSec % 60) ];
|
||||
}
|
||||
|
||||
+(NSString *) recordingDuration:(NSString *) _voiceRecordingFile{
|
||||
NSError *error = nil;
|
||||
AVAudioPlayer* utilityPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL URLWithString:_voiceRecordingFile] error:&error]; // Workaround as opening multiple linphone_players at the same time can cause crash (here for example layout refreshed whilst a voice memo is playing
|
||||
return [self formattedDuration:utilityPlayer.duration];
|
||||
utilityPlayer = nil;
|
||||
LinphonePlayer *p = linphone_core_create_local_player(LC, nil, nil, nil);
|
||||
linphone_player_open(p, _voiceRecordingFile.UTF8String);
|
||||
NSString *result = [self formattedDuration:linphone_player_get_duration(p)];
|
||||
linphone_player_close(p);
|
||||
return result;
|
||||
}
|
||||
|
||||
+ (UIImage *)getImageFromFileName:(NSString *)fileName forReplyBubble:(BOOL)forReplyBubbble {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue