VoiceWake: autoplay chime on selection
This commit is contained in:
@@ -234,11 +234,11 @@ struct VoiceWakeSettings: View {
|
|||||||
.frame(width: self.fieldLabelWidth, alignment: .leading)
|
.frame(width: self.fieldLabelWidth, alignment: .leading)
|
||||||
|
|
||||||
Menu {
|
Menu {
|
||||||
Button("No Sound") { selection.wrappedValue = .none }
|
Button("No Sound") { self.selectChime(.none, binding: selection) }
|
||||||
Divider()
|
Divider()
|
||||||
ForEach(VoiceWakeChimeCatalog.systemOptions, id: \.self) { option in
|
ForEach(VoiceWakeChimeCatalog.systemOptions, id: \.self) { option in
|
||||||
Button(VoiceWakeChimeCatalog.displayName(for: option)) {
|
Button(VoiceWakeChimeCatalog.displayName(for: option)) {
|
||||||
selection.wrappedValue = .system(name: option)
|
self.selectChime(.system(name: option), binding: selection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Divider()
|
Divider()
|
||||||
@@ -282,13 +282,20 @@ struct VoiceWakeSettings: View {
|
|||||||
options: [.withSecurityScope],
|
options: [.withSecurityScope],
|
||||||
includingResourceValuesForKeys: nil,
|
includingResourceValuesForKeys: nil,
|
||||||
relativeTo: nil)
|
relativeTo: nil)
|
||||||
selection.wrappedValue = .custom(displayName: url.lastPathComponent, bookmark: bookmark)
|
let chosen = VoiceWakeChime.custom(displayName: url.lastPathComponent, bookmark: bookmark)
|
||||||
|
selection.wrappedValue = chosen
|
||||||
|
VoiceWakeChimePlayer.play(chosen)
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore failures; user can retry.
|
// Ignore failures; user can retry.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func selectChime(_ chime: VoiceWakeChime, binding: Binding<VoiceWakeChime>) {
|
||||||
|
binding.wrappedValue = chime
|
||||||
|
VoiceWakeChimePlayer.play(chime)
|
||||||
|
}
|
||||||
|
|
||||||
private func sanitizedTriggers() -> [String] {
|
private func sanitizedTriggers() -> [String] {
|
||||||
sanitizeVoiceWakeTriggers(self.state.swabbleTriggerWords)
|
sanitizeVoiceWakeTriggers(self.state.swabbleTriggerWords)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user