setPlaybackProgress can take an attachment instead of stream
This commit is contained in:
parent
528a5c1562
commit
da14a07bc9
@ -209,12 +209,12 @@ public class CVAudioPlayer: NSObject {
|
||||
|
||||
public func setPlaybackProgress(
|
||||
progress: TimeInterval,
|
||||
forAttachmentStream attachmentStream: AttachmentStream,
|
||||
forAttachment attachment: Attachment,
|
||||
) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
progressCache[attachmentStream.id] = progress
|
||||
if let audioPlayback, audioPlayback.attachmentId == attachmentStream.id {
|
||||
progressCache[attachment.id] = progress
|
||||
if let audioPlayback, audioPlayback.attachmentId == attachment.id {
|
||||
audioPlayback.setProgress(progress)
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,9 +300,6 @@ public class CVComponentAudioAttachment: CVComponentBase, CVComponent {
|
||||
return
|
||||
}
|
||||
let location = sender.location(in: audioMessageView)
|
||||
guard let attachmentStream else {
|
||||
return
|
||||
}
|
||||
switch sender.state {
|
||||
case .changed:
|
||||
let progress = audioMessageView.progressForLocation(location)
|
||||
@ -312,7 +309,10 @@ public class CVComponentAudioAttachment: CVComponentBase, CVComponent {
|
||||
// we still call `scrubToLocation` above in order to update the slider.
|
||||
audioMessageView.clearOverrideProgress(animated: false)
|
||||
let scrubbedTime = audioMessageView.scrubToLocation(location)
|
||||
AppEnvironment.shared.cvAudioPlayerRef.setPlaybackProgress(progress: scrubbedTime, forAttachmentStream: attachmentStream)
|
||||
AppEnvironment.shared.cvAudioPlayerRef.setPlaybackProgress(
|
||||
progress: scrubbedTime,
|
||||
forAttachment: attachment,
|
||||
)
|
||||
case .possible, .began, .failed, .cancelled:
|
||||
audioMessageView.clearOverrideProgress(animated: false)
|
||||
@unknown default:
|
||||
|
||||
@ -266,7 +266,7 @@ class AudioCell: MediaTileListModeCell {
|
||||
let cvAudioPlayer = AppEnvironment.shared.cvAudioPlayerRef
|
||||
cvAudioPlayer.setPlaybackProgress(
|
||||
progress: scrubbedTime,
|
||||
forAttachmentStream: audioItem.attachmentStream.attachmentStream,
|
||||
forAttachment: audioItem.attachmentStream.attachment,
|
||||
)
|
||||
case .possible, .failed, .cancelled:
|
||||
audioMessageView.clearOverrideProgress(animated: false)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user