mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
UI for changing playback rate
This commit is contained in:
parent
c4bbf4f618
commit
8db3b397d7
3 changed files with 30 additions and 6 deletions
|
|
@ -248,14 +248,14 @@ public struct MiniPlayer: View {
|
|||
|
||||
HStack {
|
||||
Menu {
|
||||
Button("1.0×", action: {})
|
||||
Button("1.2×", action: {})
|
||||
Button("1.5×", action: {})
|
||||
Button("1.7×", action: {})
|
||||
Button("2.0×", action: {})
|
||||
playbackRateButton(rate: 1.0, title: "1.0×", selected: audioController.playbackRate == 1.0)
|
||||
playbackRateButton(rate: 1.2, title: "1.2×", selected: audioController.playbackRate == 1.2)
|
||||
playbackRateButton(rate: 1.5, title: "1.5×", selected: audioController.playbackRate == 1.5)
|
||||
playbackRateButton(rate: 1.7, title: "1.7×", selected: audioController.playbackRate == 1.7)
|
||||
playbackRateButton(rate: 2.0, title: "2.0×", selected: audioController.playbackRate == 2.0)
|
||||
} label: {
|
||||
VStack {
|
||||
Text("1.0×")
|
||||
Text(String(format: "%.1f×", audioController.playbackRate))
|
||||
.font(.appCallout)
|
||||
.lineLimit(0)
|
||||
}
|
||||
|
|
@ -312,6 +312,22 @@ public struct MiniPlayer: View {
|
|||
}
|
||||
}
|
||||
|
||||
func playbackRateButton(rate: Double, title: String, selected: Bool) -> some View {
|
||||
Button(action: {
|
||||
audioController.playbackRate = rate
|
||||
}) {
|
||||
HStack {
|
||||
Text(title)
|
||||
Spacer()
|
||||
if selected {
|
||||
Image(systemName: "checkmark")
|
||||
}
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
ZStack(alignment: .center) {
|
||||
presentingView
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import CryptoKit
|
|||
import Foundation
|
||||
import MediaPlayer
|
||||
import Models
|
||||
import SwiftUI
|
||||
import Utils
|
||||
|
||||
public enum AudioControllerState {
|
||||
|
|
@ -235,6 +236,12 @@ public class AudioController: NSObject, ObservableObject, AVAudioPlayerDelegate,
|
|||
}
|
||||
}
|
||||
|
||||
@AppStorage(UserDefaultKey.textToSpeechPlaybackRate.rawValue) public var playbackRate = 1.0 {
|
||||
didSet {
|
||||
print("setting textToSpeechPlaybackRate: ", playbackRate)
|
||||
}
|
||||
}
|
||||
|
||||
public var currentVoice: String {
|
||||
get {
|
||||
UserDefaults.standard.string(forKey: Keys.textToSpeechVoice) ?? "en-US-JennyNeural"
|
||||
|
|
|
|||
|
|
@ -14,4 +14,5 @@ public enum UserDefaultKey: String {
|
|||
case lastUsedAppBuildNumber
|
||||
case lastItemSyncTime
|
||||
case audioInfoAlertShown
|
||||
case textToSpeechPlaybackRate
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue