I have a custom rotor that changes the skim speed of the skim forward/backward feature of my audio player. The rotor works, but it's always playing an end-of-list sound.
Here is the code:
// Member variables
private let accessibilitySeekSpeeds: [Double] = [10, 30, 60, 180] // seconds
private var accessibilitySeekSpeedIndex: Int = 0
func seekSpeedRotor() -> UIAccessibilityCustomRotor {
UIAccessibilityCustomRotor(name: "seek speed") { [weak self] predicate in
guard let self = self else { return nil }
let speeds = accessibilitySeekSpeeds
switch predicate.searchDirection {
case .previous:
accessibilitySeekSpeedIndex = (accessibilitySeekSpeedIndex - 1 + speeds.count) % speeds.count
case .next:
accessibilitySeekSpeedIndex = (accessibilitySeekSpeedIndex + 1) % speeds.count
@unknown default:
break
}
// Return the currently selected speed as an accessibility element
let accessibilityElement = UIAccessibilityElement(accessibilityContainer: self)
let currentSpeed = localizedDuration(seconds: speeds[accessibilitySeekSpeedIndex])
accessibilityElement.accessibilityLabel = currentSpeed + " seek speed"
UIAccessibility.post(notification: .announcement, argument: currentSpeed + " seek speed")
return UIAccessibilityCustomRotorItemResult(targetElement: accessibilityElement, targetRange: nil)
}
}
The returned accessibility element isn't read out, and instead an end-of-list sound is played. I can announce the change manually using UIAccessibility.post, but it still plays the end-of-list sound.
How can I prevent the rotor from playing the end-of-list sound?