Add rate change selector

This commit is contained in:
Arkadiusz Fal
2022-04-16 22:50:37 +02:00
parent d58ec0684c
commit c4fd6aca24
5 changed files with 49 additions and 4 deletions

View File

@@ -176,8 +176,10 @@ struct PlayerControls: View {
HStack {
#if !os(tvOS)
fullscreenButton
rateButton
Spacer()
#endif
Spacer()
// button("Music Mode", systemImage: "music.note")
}
}
@@ -194,6 +196,41 @@ struct PlayerControls: View {
#endif
}
private var rateButton: some View {
#if os(macOS)
ratePicker
.labelsHidden()
.frame(maxWidth: 70)
#else
Menu {
ratePicker
.frame(width: 45, height: 30)
#if os(iOS)
.background(VisualEffectBlur(blurStyle: .systemThinMaterial))
#endif
.mask(RoundedRectangle(cornerRadius: 3))
} label: {
Text(player.rateLabel(player.currentRate))
.foregroundColor(.primary)
.frame(maxWidth: .infinity)
}
#endif
}
var ratePicker: some View {
Picker("Rate", selection: rateBinding) {
ForEach(PlayerModel.availableRates, id: \.self) { rate in
Text(player.rateLabel(rate)).tag(rate)
}
}
.transaction { t in t.animation = .none }
}
private var rateBinding: Binding<Float> {
.init(get: { player.currentRate }, set: { rate in player.currentRate = rate })
}
var mediumButtonsBar: some View {
HStack {
#if !os(tvOS)