Reputation: 65
I'm trying to incorporate a slow playback speed button into my audio player. It works as expected if I hit the button and then rewind the audio a little bit using the slider. However, if the audio is playing and I just hit the button, the audio will continue to play at the same rate. Is there anyway to get this to slow the audio down that is currently playing instead of having to restart or rewind it?
PlaybackControlButton(systemName: "tortoise.fill", color: slowColor) {
player.enableRate = true
if !audioManager.isSlowPlayback {
player.rate = 0.5
audioManager.togglePlayback()
}else {
player.rate = 1.0
audioManager.togglePlayback()
}
}
Upvotes: 1
Views: 115
Reputation: 65
I had to set .enableRate = true
before player.play()
on my playPause
method
Upvotes: 1