Rebrand OWSAudioPlayer.
This commit is contained in:
parent
a16c2adda7
commit
38ff82ab97
|
@ -175,6 +175,8 @@
|
|||
34BECE301F7ABCF800D7438D /* GifPickerLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34BECE2F1F7ABCF800D7438D /* GifPickerLayout.swift */; };
|
||||
34C3C78D20409F320000134C /* Opening.m4r in Resources */ = {isa = PBXBuildFile; fileRef = 34C3C78C20409F320000134C /* Opening.m4r */; };
|
||||
34C3C78F2040A4F70000134C /* sonarping.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 34C3C78E2040A4F70000134C /* sonarping.mp3 */; };
|
||||
34C3C7922040B0DD0000134C /* OWSAudioPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 34C3C7902040B0DC0000134C /* OWSAudioPlayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
34C3C7932040B0DD0000134C /* OWSAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 34C3C7912040B0DC0000134C /* OWSAudioPlayer.m */; };
|
||||
34C42D5B1F45F7A80072EC04 /* OWSNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34C42D5A1F45F7A80072EC04 /* OWSNavigationController.m */; };
|
||||
34C6B0A91FA0E46F00D35993 /* test-gif.gif in Resources */ = {isa = PBXBuildFile; fileRef = 34C6B0A51FA0E46F00D35993 /* test-gif.gif */; };
|
||||
34C6B0AB1FA0E46F00D35993 /* test-mp3.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 34C6B0A71FA0E46F00D35993 /* test-mp3.mp3 */; };
|
||||
|
@ -301,9 +303,7 @@
|
|||
45464DBC1DFA041F001D3FD6 /* DataChannelMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45464DBB1DFA041F001D3FD6 /* DataChannelMessage.swift */; };
|
||||
454A965A1FD6017E008D2A0E /* SignalAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D913491F62D4A500722898 /* SignalAttachment.swift */; };
|
||||
454A965B1FD601BF008D2A0E /* MediaMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34CA1C281F7164F700E51C51 /* MediaMessageView.swift */; };
|
||||
454A965D1FD602B1008D2A0E /* OWSAudioAttachmentPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 34533F161EA8D2070006114F /* OWSAudioAttachmentPlayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
454A965F1FD60EA3008D2A0E /* OWSFlatButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 454A965E1FD60EA2008D2A0E /* OWSFlatButton.swift */; };
|
||||
454A96601FD61165008D2A0E /* OWSAudioAttachmentPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 34533F171EA8D2070006114F /* OWSAudioAttachmentPlayer.m */; };
|
||||
454EBAB41F2BE14C00ACE0BB /* OWSAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D99C911F2937CC00D284D6 /* OWSAnalytics.swift */; };
|
||||
4556FA681F54AA9500AF40DD /* DebugUIProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4556FA671F54AA9500AF40DD /* DebugUIProfile.swift */; };
|
||||
455A16DD1F1FEA0000F86704 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 455A16DB1F1FEA0000F86704 /* Metal.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
|
||||
|
@ -580,8 +580,6 @@
|
|||
344F2496200FD03200CFB4F4 /* MessageApprovalViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MessageApprovalViewController.swift; path = SignalMessaging/attachments/MessageApprovalViewController.swift; sourceTree = SOURCE_ROOT; };
|
||||
344F2497200FD03200CFB4F4 /* SharingThreadPickerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SharingThreadPickerViewController.m; path = SignalMessaging/attachments/SharingThreadPickerViewController.m; sourceTree = SOURCE_ROOT; };
|
||||
344F2498200FD03200CFB4F4 /* AttachmentApprovalViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AttachmentApprovalViewController.swift; path = SignalMessaging/attachments/AttachmentApprovalViewController.swift; sourceTree = SOURCE_ROOT; };
|
||||
34533F161EA8D2070006114F /* OWSAudioAttachmentPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSAudioAttachmentPlayer.h; sourceTree = "<group>"; };
|
||||
34533F171EA8D2070006114F /* OWSAudioAttachmentPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSAudioAttachmentPlayer.m; sourceTree = "<group>"; };
|
||||
3461284A1FD0B93F00532771 /* SAELoadViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAELoadViewController.swift; sourceTree = "<group>"; };
|
||||
346129331FD1A88700532771 /* OWSSwiftUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OWSSwiftUtils.swift; sourceTree = "<group>"; };
|
||||
346129371FD1B47200532771 /* OWSPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSPreferences.h; sourceTree = "<group>"; };
|
||||
|
@ -727,6 +725,8 @@
|
|||
34BECE2F1F7ABCF800D7438D /* GifPickerLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GifPickerLayout.swift; sourceTree = "<group>"; };
|
||||
34C3C78C20409F320000134C /* Opening.m4r */ = {isa = PBXFileReference; lastKnownFileType = file; path = Opening.m4r; sourceTree = "<group>"; };
|
||||
34C3C78E2040A4F70000134C /* sonarping.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = sonarping.mp3; path = Signal/AudioFiles/sonarping.mp3; sourceTree = SOURCE_ROOT; };
|
||||
34C3C7902040B0DC0000134C /* OWSAudioPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSAudioPlayer.h; sourceTree = "<group>"; };
|
||||
34C3C7912040B0DC0000134C /* OWSAudioPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSAudioPlayer.m; sourceTree = "<group>"; };
|
||||
34C42D591F45F7A80072EC04 /* OWSNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSNavigationController.h; sourceTree = "<group>"; };
|
||||
34C42D5A1F45F7A80072EC04 /* OWSNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSNavigationController.m; sourceTree = "<group>"; };
|
||||
34C42D621F4734ED0072EC04 /* OWSContactOffersInteraction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactOffersInteraction.h; sourceTree = "<group>"; };
|
||||
|
@ -1224,6 +1224,8 @@
|
|||
348F2EAD1F0D21BC00D4ECE0 /* DeviceSleepManager.swift */,
|
||||
344F248C2007CCD600CFB4F4 /* DisplayableText.swift */,
|
||||
346129AC1FD1F34E00532771 /* ImageCache.swift */,
|
||||
34C3C7902040B0DC0000134C /* OWSAudioPlayer.h */,
|
||||
34C3C7912040B0DC0000134C /* OWSAudioPlayer.m */,
|
||||
45666EC41D99483D008FE134 /* OWSAvatarBuilder.h */,
|
||||
45666EC51D99483D008FE134 /* OWSAvatarBuilder.m */,
|
||||
45855F351D9498A40084F340 /* OWSContactAvatarBuilder.h */,
|
||||
|
@ -1709,8 +1711,6 @@
|
|||
children = (
|
||||
34B3F8391E8DF1700035BE1A /* AttachmentSharing.h */,
|
||||
34B3F83A1E8DF1700035BE1A /* AttachmentSharing.m */,
|
||||
34533F161EA8D2070006114F /* OWSAudioAttachmentPlayer.h */,
|
||||
34533F171EA8D2070006114F /* OWSAudioAttachmentPlayer.m */,
|
||||
34D913491F62D4A500722898 /* SignalAttachment.swift */,
|
||||
34CA1C281F7164F700E51C51 /* MediaMessageView.swift */,
|
||||
45BC829C1FD9C4B400011CF3 /* ShareViewDelegate.swift */,
|
||||
|
@ -2197,12 +2197,12 @@
|
|||
451F8A4B1FD715E1005CB9DA /* OWSGroupAvatarBuilder.h in Headers */,
|
||||
347850721FDAEB17007B8332 /* OWSUserProfile.h in Headers */,
|
||||
451F8A371FD71179005CB9DA /* OWSViewController.h in Headers */,
|
||||
454A965D1FD602B1008D2A0E /* OWSAudioAttachmentPlayer.h in Headers */,
|
||||
451F8A3E1FD713D2005CB9DA /* ThreadViewHelper.h in Headers */,
|
||||
346129391FD1B47300532771 /* OWSPreferences.h in Headers */,
|
||||
344D6CED20069E070042AF96 /* NewNonContactConversationViewController.h in Headers */,
|
||||
346129DE1FD5C02A00532771 /* LockInteractionController.h in Headers */,
|
||||
451F8A451FD71570005CB9DA /* BlockListUIUtils.h in Headers */,
|
||||
34C3C7922040B0DD0000134C /* OWSAudioPlayer.h in Headers */,
|
||||
451F8A4A1FD715D9005CB9DA /* OWSContactAvatarBuilder.h in Headers */,
|
||||
34480B5B1FD0A7E300BC14EF /* SignalMessaging-Prefix.pch in Headers */,
|
||||
45194F921FD7215600333B2C /* OWSContactOffersInteraction.h in Headers */,
|
||||
|
@ -2927,6 +2927,7 @@
|
|||
34480B621FD0A98800BC14EF /* UIColor+OWS.m in Sources */,
|
||||
34480B531FD0A7A400BC14EF /* OWSLogger.m in Sources */,
|
||||
34480B641FD0A98800BC14EF /* UIView+OWS.m in Sources */,
|
||||
34C3C7932040B0DD0000134C /* OWSAudioPlayer.m in Sources */,
|
||||
3461293A1FD1B47300532771 /* OWSPreferences.m in Sources */,
|
||||
344F248520069E9C00CFB4F4 /* CountryCodeViewController.m in Sources */,
|
||||
34480B671FD0AA9400BC14EF /* UIFont+OWS.m in Sources */,
|
||||
|
@ -2979,7 +2980,6 @@
|
|||
34612A071FD7238600532771 /* OWSContactsSyncing.m in Sources */,
|
||||
346129DF1FD5C02A00532771 /* LockInteractionController.m in Sources */,
|
||||
451F8A471FD715BA005CB9DA /* OWSAvatarBuilder.m in Sources */,
|
||||
454A96601FD61165008D2A0E /* OWSAudioAttachmentPlayer.m in Sources */,
|
||||
344D6CEB20069E070042AF96 /* SelectRecipientViewController.m in Sources */,
|
||||
34480B591FD0A7A400BC14EF /* OWSScrubbingLogFormatter.m in Sources */,
|
||||
451F8A441FD7156B005CB9DA /* BlockListUIUtils.m in Sources */,
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#import "NSString+OWS.h"
|
||||
#import "NotificationsManager.h"
|
||||
#import "OWSAnyTouchGestureRecognizer.h"
|
||||
#import "OWSAudioAttachmentPlayer.h"
|
||||
#import "OWSAudioPlayer.h"
|
||||
#import "OWSBezierPathView.h"
|
||||
#import "OWSCallNotificationsAdaptee.h"
|
||||
#import "OWSDatabaseMigration.h"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSAudioAttachmentPlayer.h"
|
||||
#import "OWSAudioPlayer.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#import "MediaDetailViewController.h"
|
||||
#import "NSAttributedString+OWS.h"
|
||||
#import "NewGroupViewController.h"
|
||||
#import "OWSAudioAttachmentPlayer.h"
|
||||
#import "OWSAudioPlayer.h"
|
||||
#import "OWSContactOffersCell.h"
|
||||
#import "OWSConversationSettingsViewController.h"
|
||||
#import "OWSConversationSettingsViewDelegate.h"
|
||||
|
@ -172,7 +172,7 @@ typedef enum : NSUInteger {
|
|||
@property (nonatomic) NSMutableDictionary<NSString *, ConversationViewItem *> *viewItemCache;
|
||||
|
||||
@property (nonatomic, nullable) AVAudioRecorder *audioRecorder;
|
||||
@property (nonatomic, nullable) OWSAudioAttachmentPlayer *audioAttachmentPlayer;
|
||||
@property (nonatomic, nullable) OWSAudioPlayer *audioAttachmentPlayer;
|
||||
@property (nonatomic, nullable) NSUUID *voiceMessageUUID;
|
||||
|
||||
@property (nonatomic, nullable) NSTimer *readTimer;
|
||||
|
@ -2077,8 +2077,7 @@ typedef enum : NSUInteger {
|
|||
[self.audioAttachmentPlayer stop];
|
||||
self.audioAttachmentPlayer = nil;
|
||||
}
|
||||
self.audioAttachmentPlayer =
|
||||
[[OWSAudioAttachmentPlayer alloc] initWithMediaUrl:attachmentStream.mediaURL delegate:viewItem];
|
||||
self.audioAttachmentPlayer = [[OWSAudioPlayer alloc] initWithMediaUrl:attachmentStream.mediaURL delegate:viewItem];
|
||||
// Associate the player with this media adapter.
|
||||
self.audioAttachmentPlayer.owner = viewItem;
|
||||
[self.audioAttachmentPlayer play];
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ConversationViewLayout.h"
|
||||
#import "OWSAudioAttachmentPlayer.h"
|
||||
#import "OWSAudioPlayer.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
@ -38,7 +38,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
|
|||
//
|
||||
// Critically, this class implements ConversationViewLayoutItem
|
||||
// and does caching of the cell's size.
|
||||
@interface ConversationViewItem : NSObject <ConversationViewLayoutItem, OWSAudioAttachmentPlayerDelegate>
|
||||
@interface ConversationViewItem : NSObject <ConversationViewLayoutItem, OWSAudioPlayerDelegate>
|
||||
|
||||
@property (nonatomic, readonly) TSInteraction *interaction;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
|
||||
@property (nonatomic, nullable) NSValue *cachedCellSize;
|
||||
|
||||
#pragma mark - OWSAudioAttachmentPlayerDelegate
|
||||
#pragma mark - OWSAudioPlayerDelegate
|
||||
|
||||
@property (nonatomic) AudioPlaybackState audioPlaybackState;
|
||||
@property (nonatomic) CGFloat audioProgressSeconds;
|
||||
|
@ -242,7 +242,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
}
|
||||
}
|
||||
|
||||
#pragma mark - OWSAudioAttachmentPlayerDelegate
|
||||
#pragma mark - OWSAudioPlayerDelegate
|
||||
|
||||
- (void)setAudioPlaybackState:(AudioPlaybackState)audioPlaybackState
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#import "OWSSoundSettingsViewController.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <SignalMessaging/OWSAudioPlayer.h>
|
||||
#import <SignalMessaging/OWSSounds.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
@ -14,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@property (nonatomic) OWSSound currentSound;
|
||||
|
||||
@property (nonatomic, nullable) AVAudioPlayer *audioPlayer;
|
||||
@property (nonatomic, nullable) OWSAudioPlayer *audioPlayer;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -108,7 +109,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self.audioPlayer stop];
|
||||
self.audioPlayer = [OWSSounds audioPlayerForSound:sound];
|
||||
// Suppress looping in this view.
|
||||
self.audioPlayer.numberOfLoops = 0;
|
||||
self.audioPlayer.isLooping = NO;
|
||||
[self.audioPlayer play];
|
||||
|
||||
if (self.currentSound == sound) {
|
||||
|
|
|
@ -383,7 +383,7 @@ protocol CallAudioServiceDelegate: class {
|
|||
|
||||
// MARK: Playing Sounds
|
||||
|
||||
var currentPlayer: AVAudioPlayer?
|
||||
var currentPlayer: OWSAudioPlayer?
|
||||
|
||||
private func stopPlayingAnySounds() {
|
||||
currentPlayer?.stop()
|
||||
|
|
|
@ -19,7 +19,7 @@ FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[];
|
|||
#import <SignalMessaging/DebugLogger.h>
|
||||
#import <SignalMessaging/Environment.h>
|
||||
#import <SignalMessaging/NSString+OWS.h>
|
||||
#import <SignalMessaging/OWSAudioAttachmentPlayer.h>
|
||||
#import <SignalMessaging/OWSAudioPlayer.h>
|
||||
#import <SignalMessaging/OWSContactAvatarBuilder.h>
|
||||
#import <SignalMessaging/OWSContactOffersInteraction.h>
|
||||
#import <SignalMessaging/OWSContactsManager.h>
|
||||
|
|
|
@ -20,7 +20,7 @@ public protocol MediaDetailPresenter: class {
|
|||
}
|
||||
|
||||
@objc
|
||||
public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
|
||||
public class MediaMessageView: UIView, OWSAudioPlayerDelegate {
|
||||
|
||||
let TAG = "[MediaMessageView]"
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
|
|||
public let attachment: SignalAttachment
|
||||
|
||||
@objc
|
||||
public var audioPlayer: OWSAudioAttachmentPlayer?
|
||||
public var audioPlayer: OWSAudioPlayer?
|
||||
|
||||
@objc
|
||||
public var audioPlayButton: UIButton?
|
||||
|
@ -143,7 +143,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
|
|||
return
|
||||
}
|
||||
|
||||
audioPlayer = OWSAudioAttachmentPlayer(mediaUrl: dataUrl, delegate: self)
|
||||
audioPlayer = OWSAudioPlayer(mediaUrl: dataUrl, delegate: self)
|
||||
|
||||
var subviews = [UIView]()
|
||||
|
||||
|
@ -201,11 +201,11 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
|
|||
let animatedImageView = YYAnimatedImageView()
|
||||
animatedImageView.image = image
|
||||
let aspectRatio = image.size.width / image.size.height
|
||||
addSubviewWithScaleAspectFitLayout(view:animatedImageView, aspectRatio:aspectRatio)
|
||||
addSubviewWithScaleAspectFitLayout(view: animatedImageView, aspectRatio: aspectRatio)
|
||||
contentView = animatedImageView
|
||||
|
||||
animatedImageView.isUserInteractionEnabled = true
|
||||
animatedImageView.addGestureRecognizer(UITapGestureRecognizer(target:self, action:#selector(imageTapped)))
|
||||
animatedImageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(imageTapped)))
|
||||
}
|
||||
|
||||
private func addSubviewWithScaleAspectFitLayout(view: UIView, aspectRatio: CGFloat) {
|
||||
|
@ -216,7 +216,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
|
|||
// This allows ConversationInputToolbar to place the "cancel" button
|
||||
// in the upper-right hand corner of the preview content.
|
||||
view.autoCenterInSuperview()
|
||||
view.autoPin(toAspectRatio:aspectRatio)
|
||||
view.autoPin(toAspectRatio: aspectRatio)
|
||||
view.autoMatch(.width, to: .width, of: self, withMultiplier: 1.0, relation: .lessThanOrEqual)
|
||||
view.autoMatch(.height, to: .height, of: self, withMultiplier: 1.0, relation: .lessThanOrEqual)
|
||||
}
|
||||
|
@ -235,11 +235,11 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
|
|||
imageView.layer.minificationFilter = kCAFilterTrilinear
|
||||
imageView.layer.magnificationFilter = kCAFilterTrilinear
|
||||
let aspectRatio = image.size.width / image.size.height
|
||||
addSubviewWithScaleAspectFitLayout(view:imageView, aspectRatio:aspectRatio)
|
||||
addSubviewWithScaleAspectFitLayout(view: imageView, aspectRatio: aspectRatio)
|
||||
contentView = imageView
|
||||
|
||||
imageView.isUserInteractionEnabled = true
|
||||
imageView.addGestureRecognizer(UITapGestureRecognizer(target:self, action:#selector(imageTapped)))
|
||||
imageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(imageTapped)))
|
||||
}
|
||||
|
||||
private func createVideoPreview() {
|
||||
|
@ -256,13 +256,13 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
|
|||
imageView.layer.minificationFilter = kCAFilterTrilinear
|
||||
imageView.layer.magnificationFilter = kCAFilterTrilinear
|
||||
let aspectRatio = image.size.width / image.size.height
|
||||
addSubviewWithScaleAspectFitLayout(view:imageView, aspectRatio:aspectRatio)
|
||||
addSubviewWithScaleAspectFitLayout(view: imageView, aspectRatio: aspectRatio)
|
||||
contentView = imageView
|
||||
|
||||
// attachment approval provides it's own play button to keep it
|
||||
// at the proper zoom scale.
|
||||
if mode != .attachmentApproval {
|
||||
let videoPlayIcon = UIImage(named:"play_button")!
|
||||
let videoPlayIcon = UIImage(named: "play_button")!
|
||||
let videoPlayButton = UIImageView(image: videoPlayIcon)
|
||||
self.videoPlayButton = videoPlayButton
|
||||
videoPlayButton.contentMode = .scaleAspectFit
|
||||
|
@ -270,7 +270,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
|
|||
videoPlayButton.autoCenterInSuperview()
|
||||
|
||||
imageView.isUserInteractionEnabled = true
|
||||
imageView.addGestureRecognizer(UITapGestureRecognizer(target:self, action:#selector(videoTapped)))
|
||||
imageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(videoTapped)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
|
|||
audioPlayer?.togglePlayState()
|
||||
}
|
||||
|
||||
// MARK: - OWSAudioAttachmentPlayerDelegate
|
||||
// MARK: - OWSAudioPlayerDelegate
|
||||
|
||||
public func audioPlaybackState() -> AudioPlaybackState {
|
||||
return playbackState
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef NS_ENUM(NSUInteger, OWSSound) {
|
|||
OWSSound_DefaultiOSIncomingRingtone = OWSSound_Opening,
|
||||
};
|
||||
|
||||
@class AVAudioPlayer;
|
||||
@class OWSAudioPlayer;
|
||||
@class TSThread;
|
||||
@class YapDatabaseReadWriteTransaction;
|
||||
|
||||
|
@ -64,7 +64,7 @@ typedef NS_ENUM(NSUInteger, OWSSound) {
|
|||
|
||||
#pragma mark - AudioPlayer
|
||||
|
||||
+ (nullable AVAudioPlayer *)audioPlayerForSound:(OWSSound)sound;
|
||||
+ (nullable OWSAudioPlayer *)audioPlayerForSound:(OWSSound)sound;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//
|
||||
|
||||
#import "OWSSounds.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import "OWSAudioPlayer.h"
|
||||
#import <SignalServiceKit/TSStorageManager.h>
|
||||
#import <SignalServiceKit/TSThread.h>
|
||||
#import <SignalServiceKit/YapDatabaseConnection+OWS.h>
|
||||
|
@ -16,7 +16,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob
|
|||
|
||||
@property (nonatomic, readonly) YapDatabaseConnection *dbConnection;
|
||||
|
||||
@property (nonatomic, nullable) AVAudioPlayer *audioPlayer;
|
||||
@property (nonatomic, nullable) OWSAudioPlayer *audioPlayer;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -284,25 +284,20 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob
|
|||
return (sound == OWSSound_CallConnecting || sound == OWSSound_CallOutboundRinging);
|
||||
}
|
||||
|
||||
+ (nullable AVAudioPlayer *)audioPlayerForSound:(OWSSound)sound
|
||||
+ (nullable OWSAudioPlayer *)audioPlayerForSound:(OWSSound)sound
|
||||
{
|
||||
return [self audioPlayerForSound:sound quiet:NO];
|
||||
}
|
||||
|
||||
+ (nullable AVAudioPlayer *)audioPlayerForSound:(OWSSound)sound quiet:(BOOL)quiet
|
||||
+ (nullable OWSAudioPlayer *)audioPlayerForSound:(OWSSound)sound quiet:(BOOL)quiet
|
||||
{
|
||||
NSURL *_Nullable soundURL = [OWSSounds soundURLForSound:sound quiet:(BOOL)quiet];
|
||||
if (!soundURL) {
|
||||
return nil;
|
||||
}
|
||||
NSError *error;
|
||||
AVAudioPlayer *_Nullable player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundURL error:&error];
|
||||
if (error || !player) {
|
||||
OWSFail(@"%@ audioPlayerForSound failed with error: %@.", self.logTag, error);
|
||||
return nil;
|
||||
}
|
||||
OWSAudioPlayer *player = [[OWSAudioPlayer alloc] initWithMediaUrl:soundURL];
|
||||
if ([self shouldAudioPlayerLoopForSound:sound]) {
|
||||
player.numberOfLoops = -1;
|
||||
player.isLooping = YES;
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
|
|
@ -4,15 +4,13 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TSVideoAttachmentAdapter;
|
||||
|
||||
typedef NS_ENUM(NSInteger, AudioPlaybackState) {
|
||||
AudioPlaybackState_Stopped,
|
||||
AudioPlaybackState_Playing,
|
||||
AudioPlaybackState_Paused,
|
||||
};
|
||||
|
||||
@protocol OWSAudioAttachmentPlayerDelegate <NSObject>
|
||||
@protocol OWSAudioPlayerDelegate <NSObject>
|
||||
|
||||
- (AudioPlaybackState)audioPlaybackState;
|
||||
- (void)setAudioPlaybackState:(AudioPlaybackState)state;
|
||||
|
@ -23,16 +21,19 @@ typedef NS_ENUM(NSInteger, AudioPlaybackState) {
|
|||
|
||||
#pragma mark -
|
||||
|
||||
@interface OWSAudioAttachmentPlayer : NSObject
|
||||
@interface OWSAudioPlayer : NSObject
|
||||
|
||||
@property (nonatomic, readonly, weak) id<OWSAudioAttachmentPlayerDelegate> delegate;
|
||||
@property (nonatomic, readonly, weak) id<OWSAudioPlayerDelegate> delegate;
|
||||
|
||||
// This property can be used to associate instances of the player with view
|
||||
// or model objects.
|
||||
@property (nonatomic, weak) id owner;
|
||||
|
||||
// An generic initializer.
|
||||
- (instancetype)initWithMediaUrl:(NSURL *)mediaUrl delegate:(id<OWSAudioAttachmentPlayerDelegate>)delegate;
|
||||
@property (nonatomic) BOOL isLooping;
|
||||
|
||||
- (instancetype)initWithMediaUrl:(NSURL *)mediaUrl;
|
||||
|
||||
- (instancetype)initWithMediaUrl:(NSURL *)mediaUrl delegate:(id<OWSAudioPlayerDelegate>)delegate;
|
||||
|
||||
- (void)play;
|
||||
- (void)pause;
|
|
@ -2,7 +2,7 @@
|
|||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSAudioAttachmentPlayer.h"
|
||||
#import "OWSAudioPlayer.h"
|
||||
#import "TSAttachmentStream.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <SignalMessaging/SignalMessaging-Swift.h>
|
||||
|
@ -10,7 +10,27 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSAudioAttachmentPlayer () <AVAudioPlayerDelegate>
|
||||
// A no-op delegate implementation to be used when we don't need a delegate.
|
||||
@interface OWSAudioPlayerDelegateStub : NSObject <OWSAudioPlayerDelegate>
|
||||
|
||||
@property (nonatomic) AudioPlaybackState audioPlaybackState;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSAudioPlayerDelegateStub
|
||||
|
||||
- (void)setAudioProgress:(CGFloat)progress duration:(CGFloat)duration
|
||||
{
|
||||
// Do nothing;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@interface OWSAudioPlayer () <AVAudioPlayerDelegate>
|
||||
|
||||
@property (nonatomic, readonly) NSURL *mediaUrl;
|
||||
@property (nonatomic, nullable) AVAudioPlayer *audioPlayer;
|
||||
|
@ -21,9 +41,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
#pragma mark -
|
||||
|
||||
@implementation OWSAudioAttachmentPlayer
|
||||
@implementation OWSAudioPlayer
|
||||
|
||||
- (instancetype)initWithMediaUrl:(NSURL *)mediaUrl delegate:(id<OWSAudioAttachmentPlayerDelegate>)delegate
|
||||
- (instancetype)initWithMediaUrl:(NSURL *)mediaUrl
|
||||
{
|
||||
return [self initWithMediaUrl:mediaUrl delegate:[OWSAudioPlayerDelegateStub new]];
|
||||
}
|
||||
|
||||
- (instancetype)initWithMediaUrl:(NSURL *)mediaUrl delegate:(id<OWSAudioPlayerDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
|
@ -92,6 +117,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return;
|
||||
}
|
||||
self.audioPlayer.delegate = self;
|
||||
if (self.isLooping) {
|
||||
self.audioPlayer.numberOfLoops = -1;
|
||||
}
|
||||
}
|
||||
|
||||
[self.audioPlayer play];
|
Loading…
Reference in New Issue