Simplify scrubbing and reset to stopped if scrub to start/end

This commit is contained in:
David Langley
2021-09-22 11:12:45 +01:00
parent 187d1d316c
commit d3c3643098
4 changed files with 27 additions and 62 deletions
@@ -97,17 +97,14 @@ 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
guard progress > 0 else {
audioPlayer.stop()
return
}
if audioPlayer.url == nil,
@@ -116,7 +113,9 @@ class VoiceMessagePlaybackController: VoiceMessageAudioPlayerDelegate, VoiceMess
}
audioPlayer.seekToTime(self.duration * progress) { [weak self] _ in
self?.updateUI()
guard let self = self else { return }
self.state = .paused
self.updateUI()
}
}