Show alert when user tries to play an invalid audio file.

// FREEBIE
pull/1/head
Matthew Chen 7 years ago
parent 07c39d9242
commit 3e8b4225b3

@ -340,6 +340,11 @@ NS_ASSUME_NONNULL_BEGIN
if (self.audioDurationSeconds == 0.f) {
NSError *error;
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:self.fileURL error:&error];
if (error && [error.domain isEqualToString:NSOSStatusErrorDomain]
&& (error.code == kAudioFileInvalidFileError || error.code == kAudioFileStreamError_InvalidFile)) {
// Ignore "invalid audio file" errors.
return;
}
OWSAssert(!error);
if (!error) {
self.audioDurationSeconds = (CGFloat)[audioPlayer duration];

@ -3,6 +3,7 @@
//
#import "OWSAudioAttachmentPlayer.h"
#import "Signal-Swift.h"
#import "TSAttachment.h"
#import "TSAttachmentStream.h"
#import "TSVideoAttachmentAdapter.h"
@ -111,6 +112,14 @@ NS_ASSUME_NONNULL_BEGIN
if (error) {
DDLogError(@"%@ error: %@", self.tag, error);
[self stop];
if ([error.domain isEqualToString:NSOSStatusErrorDomain]
&& (error.code == kAudioFileInvalidFileError || error.code == kAudioFileStreamError_InvalidFile)) {
[OWSAlerts showAlertWithTitle:NSLocalizedString(@"ALERT_ERROR_TITLE", @"")
message:NSLocalizedString(@"INVALID_AUDIO_FILE_ALERT_ERROR_MESSAGE",
@"Message for the alert indicating that an audio file is invalid.")];
}
return;
}
self.audioPlayer.delegate = self;

@ -580,6 +580,9 @@
/* No comment provided by engineer. */
"INCOMING_INCOMPLETE_CALL" = "Incomplete incoming call from";
/* Message for the alert indicating that an audio file is invalid. */
"INVALID_AUDIO_FILE_ALERT_ERROR_MESSAGE" = "Invalid audio file.";
/* Alert body when contacts disabled while trying to invite contacts to signal */
"INVITE_FLOW_REQUIRES_CONTACT_ACCESS_BODY" = "To invite your contacts, you need to allow Signal access to your contacts in the Settings app.";

Loading…
Cancel
Save