How do I recognize fast-forward and rewind gestures for an audio player?

263 views Asked by At

I'm developing a tvOS application with an audio player, and I need to support fast-forward and rewind using the same gestures as Apple Music and other audio apps. Specifically, to fast-forward, the user presses and holds on the right side of the remote control's touch surface, and to rewind, the user presses and holds on the left side.

I'm creating two UILongPressGestureRecognizer instances, one for fast-forward and one for rewind, and adding them to the view controller's top-level view. For the fast-forward gesture recognizer, I'm setting allowedPressTypes to @[UIPressTypeRightArrow], and for the rewind recognizer, I'm setting allowedPressTypes to @[UIPressTypeLeftArrow]. But these gestures have no effect.

Can anyone provide sample code that implements these gestures properly?

1

There are 1 answers

0
HackyStack On

Don't set those allowedPressTypes and it will work. You'll have to determine where the user tapped in your handler, but the gestures will register.