Debug
This commit is contained in:
parent
f18a4a60a1
commit
cc424a9a38
|
@ -3,6 +3,7 @@ import Accelerate
|
||||||
@objc(LKVoiceMessageView2)
|
@objc(LKVoiceMessageView2)
|
||||||
final class VoiceMessageView2 : UIView {
|
final class VoiceMessageView2 : UIView {
|
||||||
private let voiceMessage: TSAttachment
|
private let voiceMessage: TSAttachment
|
||||||
|
private let isOutgoing: Bool
|
||||||
private var isAnimating = false
|
private var isAnimating = false
|
||||||
private var volumeSamples: [Float] = [] { didSet { updateShapeLayers() } }
|
private var volumeSamples: [Float] = [] { didSet { updateShapeLayers() } }
|
||||||
private var progress: CGFloat = 0
|
private var progress: CGFloat = 0
|
||||||
|
@ -30,7 +31,7 @@ final class VoiceMessageView2 : UIView {
|
||||||
|
|
||||||
private lazy var foregroundShapeLayer: CAShapeLayer = {
|
private lazy var foregroundShapeLayer: CAShapeLayer = {
|
||||||
let result = CAShapeLayer()
|
let result = CAShapeLayer()
|
||||||
result.fillColor = isLightMode ? UIColor.white.cgColor : Colors.accent.cgColor
|
result.fillColor = (isLightMode && isOutgoing) ? UIColor.white.cgColor : Colors.accent.cgColor
|
||||||
return result
|
return result
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -41,9 +42,10 @@ final class VoiceMessageView2 : UIView {
|
||||||
@objc public static let contentHeight: CGFloat = 32
|
@objc public static let contentHeight: CGFloat = 32
|
||||||
|
|
||||||
// MARK: Initialization
|
// MARK: Initialization
|
||||||
@objc(initWithVoiceMessage:)
|
@objc(initWithVoiceMessage:isOutgoing:)
|
||||||
init(voiceMessage: TSAttachment) {
|
init(voiceMessage: TSAttachment, isOutgoing: Bool) {
|
||||||
self.voiceMessage = voiceMessage
|
self.voiceMessage = voiceMessage
|
||||||
|
self.isOutgoing = isOutgoing
|
||||||
super.init(frame: CGRect.zero)
|
super.init(frame: CGRect.zero)
|
||||||
initialize()
|
initialize()
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,9 @@ enum AudioUtilities {
|
||||||
return Promise(error: Error.noAudioTrack)
|
return Promise(error: Error.noAudioTrack)
|
||||||
}
|
}
|
||||||
let (promise, seal) = Promise<FileInfo>.pending()
|
let (promise, seal) = Promise<FileInfo>.pending()
|
||||||
asset.loadValuesAsynchronously(forKeys: [ "duration" ]) {
|
asset.loadValuesAsynchronously(forKeys: [ #keyPath(AVAsset.duration) ]) {
|
||||||
var nsError: NSError?
|
var nsError: NSError?
|
||||||
let status = asset.statusOfValue(forKey: "duration", error: &nsError)
|
let status = asset.statusOfValue(forKey: #keyPath(AVAsset.duration), error: &nsError)
|
||||||
switch status {
|
switch status {
|
||||||
case .loaded:
|
case .loaded:
|
||||||
guard let formatDescriptions = track.formatDescriptions as? [CMAudioFormatDescription],
|
guard let formatDescriptions = track.formatDescriptions as? [CMAudioFormatDescription],
|
||||||
|
|
|
@ -839,8 +839,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
OWSAssertDebug(attachment);
|
OWSAssertDebug(attachment);
|
||||||
OWSAssertDebug([attachment isAudio]);
|
OWSAssertDebug([attachment isAudio]);
|
||||||
|
|
||||||
LKVoiceMessageView2 *voiceMessageView = [[LKVoiceMessageView2 alloc] initWithVoiceMessage:attachment];
|
LKVoiceMessageView2 *voiceMessageView = [[LKVoiceMessageView2 alloc] initWithVoiceMessage:attachment isOutgoing:self.isOutgoing];
|
||||||
voiceMessageView.duration = (int)self.viewItem.audioDurationSeconds;
|
[voiceMessageView setDuration:(int)self.viewItem.audioDurationSeconds];
|
||||||
|
[voiceMessageView updateForProgress:self.viewItem.audioProgressSeconds / self.viewItem.audioDurationSeconds];
|
||||||
|
|
||||||
self.viewItem.lastAudioMessageView = voiceMessageView;
|
self.viewItem.lastAudioMessageView = voiceMessageView;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue