Merge tag '2.21.0.5'

pull/1/head
Michael Kirk 7 years ago
commit 07ee3ea843

@ -38,7 +38,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2.21.0.4</string> <string>2.21.0.5</string>
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>
<false/> <false/>
<key>LOGS_EMAIL</key> <key>LOGS_EMAIL</key>

@ -2080,7 +2080,7 @@ typedef enum : NSUInteger {
self.audioAttachmentPlayer = [[OWSAudioPlayer alloc] initWithMediaUrl:attachmentStream.mediaURL delegate:viewItem]; self.audioAttachmentPlayer = [[OWSAudioPlayer alloc] initWithMediaUrl:attachmentStream.mediaURL delegate:viewItem];
// Associate the player with this media adapter. // Associate the player with this media adapter.
self.audioAttachmentPlayer.owner = viewItem; self.audioAttachmentPlayer.owner = viewItem;
[self.audioAttachmentPlayer play]; [self.audioAttachmentPlayer playWithPlaybackAudioCategory];
} }
- (void)didTapTruncatedTextMessage:(ConversationViewItem *)conversationItem - (void)didTapTruncatedTextMessage:(ConversationViewItem *)conversationItem

@ -113,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN
self.audioPlayer = [OWSSounds audioPlayerForSound:sound]; self.audioPlayer = [OWSSounds audioPlayerForSound:sound];
// Suppress looping in this view. // Suppress looping in this view.
self.audioPlayer.isLooping = NO; self.audioPlayer.isLooping = NO;
[self.audioPlayer play]; [self.audioPlayer playWithPlaybackAudioCategory];
if (self.currentSound == sound) { if (self.currentSound == sound) {
return; return;

@ -400,7 +400,7 @@ protocol CallAudioServiceDelegate: class {
// we're playing the same sound, since the player is memoized on the sound instance, we'd otherwise // we're playing the same sound, since the player is memoized on the sound instance, we'd otherwise
// stop the sound we just started. // stop the sound we just started.
self.currentPlayer?.stop() self.currentPlayer?.stop()
newPlayer.play() newPlayer.playWithCurrentAudioCategory()
self.currentPlayer = newPlayer self.currentPlayer = newPlayer
} }

@ -238,7 +238,7 @@
} else { } else {
if (shouldPlaySound && [Environment.preferences soundInForeground]) { if (shouldPlaySound && [Environment.preferences soundInForeground]) {
OWSSound sound = [OWSSounds notificationSoundForThread:thread]; OWSSound sound = [OWSSounds notificationSoundForThread:thread];
[OWSSounds playSound:sound]; [OWSSounds playSound:sound quiet:YES shouldRespectSilentSwitch:YES];
} }
} }
}); });
@ -344,7 +344,7 @@
if (shouldPlaySound && [Environment.preferences soundInForeground]) { if (shouldPlaySound && [Environment.preferences soundInForeground]) {
OWSSound sound = [OWSSounds notificationSoundForThread:thread]; OWSSound sound = [OWSSounds notificationSoundForThread:thread];
// We play the "quiet" variation of sounds if possible for notifications in the foreground. // We play the "quiet" variation of sounds if possible for notifications in the foreground.
[OWSSounds playSound:sound quiet:YES]; [OWSSounds playSound:sound quiet:YES shouldRespectSilentSwitch:YES];
} }
} }
}); });

@ -48,8 +48,8 @@ typedef NS_ENUM(NSUInteger, OWSSound) {
+ (nullable NSString *)filenameForSound:(OWSSound)sound; + (nullable NSString *)filenameForSound:(OWSSound)sound;
+ (void)playSound:(OWSSound)sound; + (void)playSound:(OWSSound)sound shouldRespectSilentSwitch:(BOOL)shouldRespectSilentSwitch;
+ (void)playSound:(OWSSound)sound quiet:(BOOL)quiet; + (void)playSound:(OWSSound)sound quiet:(BOOL)quiet shouldRespectSilentSwitch:(BOOL)shouldRespectSilentSwitch;
#pragma mark - Notifications #pragma mark - Notifications

@ -209,21 +209,25 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob
return url; return url;
} }
+ (void)playSound:(OWSSound)sound + (void)playSound:(OWSSound)sound shouldRespectSilentSwitch:(BOOL)shouldRespectSilentSwitch
{ {
[self.sharedManager playSound:sound quiet:NO]; [self.sharedManager playSound:sound quiet:NO shouldRespectSilentSwitch:shouldRespectSilentSwitch];
} }
+ (void)playSound:(OWSSound)sound quiet:(BOOL)quiet + (void)playSound:(OWSSound)sound quiet:(BOOL)quiet shouldRespectSilentSwitch:(BOOL)shouldRespectSilentSwitch
{ {
[self.sharedManager playSound:sound quiet:quiet]; [self.sharedManager playSound:sound quiet:quiet shouldRespectSilentSwitch:shouldRespectSilentSwitch];
} }
- (void)playSound:(OWSSound)sound quiet:(BOOL)quiet - (void)playSound:(OWSSound)sound quiet:(BOOL)quiet shouldRespectSilentSwitch:(BOOL)shouldRespectSilentSwitch
{ {
[self.audioPlayer stop]; [self.audioPlayer stop];
self.audioPlayer = [OWSSounds audioPlayerForSound:sound quiet:quiet]; self.audioPlayer = [OWSSounds audioPlayerForSound:sound quiet:quiet];
[self.audioPlayer play]; if (shouldRespectSilentSwitch) {
[self.audioPlayer playWithCurrentAudioCategory];
} else {
[self.audioPlayer playWithPlaybackAudioCategory];
}
} }
#pragma mark - Notifications #pragma mark - Notifications

@ -35,7 +35,12 @@ typedef NS_ENUM(NSInteger, AudioPlaybackState) {
- (instancetype)initWithMediaUrl:(NSURL *)mediaUrl delegate:(id<OWSAudioPlayerDelegate>)delegate; - (instancetype)initWithMediaUrl:(NSURL *)mediaUrl delegate:(id<OWSAudioPlayerDelegate>)delegate;
- (void)play; // respects silent switch
- (void)playWithCurrentAudioCategory;
// will ensure sound is audible, even if silent switch is enabled
- (void)playWithPlaybackAudioCategory;
- (void)pause; - (void)pause;
- (void)stop; - (void)stop;
- (void)togglePlayState; - (void)togglePlayState;

@ -88,14 +88,28 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Methods #pragma mark - Methods
- (void)playWithCurrentAudioCategory
{
OWSAssertIsOnMainThread();
[OWSAudioSession.shared startAudioActivity:self.audioActivity];
[self play];
}
- (void)playWithPlaybackAudioCategory
{
OWSAssertIsOnMainThread();
[OWSAudioSession.shared setPlaybackCategoryWithAudioActivity:self.audioActivity];
[self play];
}
- (void)play - (void)play
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
OWSAssert(self.mediaUrl); OWSAssert(self.mediaUrl);
OWSAssert([self.delegate audioPlaybackState] != AudioPlaybackState_Playing); OWSAssert([self.delegate audioPlaybackState] != AudioPlaybackState_Playing);
[OWSAudioSession.shared setPlaybackCategoryWithAudioActivity:self.audioActivity];
[self.audioPlayerPoller invalidate]; [self.audioPlayerPoller invalidate];
self.delegate.audioPlaybackState = AudioPlaybackState_Playing; self.delegate.audioPlaybackState = AudioPlaybackState_Playing;

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>2.21.0</string> <string>2.21.0</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2.21.0.4</string> <string>2.21.0.5</string>
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>
<false/> <false/>
<key>NSAppTransportSecurity</key> <key>NSAppTransportSecurity</key>

Loading…
Cancel
Save