Add scrubbing

This commit is contained in:
David Langley
2021-09-22 09:36:20 +01:00
parent 82bcd8ce79
commit 187d1d316c
6 changed files with 147 additions and 10 deletions
@@ -97,6 +97,29 @@ class VoiceMessagePlaybackController: VoiceMessageAudioPlayerDelegate, VoiceMess
}
}
func voiceMessagePlaybackViewRequestedFormattedTimestamp(for progress: CGFloat) -> String? {
return VoiceMessagePlaybackController.timeFormatter.string(from: Date(timeIntervalSinceReferenceDate: self.duration * progress))
}
func voiceMessagePlaybackViewDidRequestSeek(to progress: CGFloat) {
guard let audioPlayer = audioPlayer else {
return
}
if state == .stopped {
state = .paused
}
if audioPlayer.url == nil,
let url = urlToLoad {
audioPlayer.loadContentFromURL(url, displayName: attachment?.originalFileName)
}
audioPlayer.seekToTime(self.duration * progress) { [weak self] _ in
self?.updateUI()
}
}
func voiceMessagePlaybackViewDidChangeWidth() {
loadAttachmentData()
}