alantoa / react-native-reanimated-player

▶️ An excellent video player controller that offers animation, performance, interactivity, and customization.
MIT License
264 stars 19 forks source link

doubleTapHandler, onStart never fires on Android #1

Closed khlling closed 2 years ago

khlling commented 2 years ago

Firstly, I found this module from your react-native-awesome-slider. I've taken some time to look through the source code and example. It's great, using reanimated v2 for this kind of animation work is the way forward.

Whilst testing the example on an Android emulator I found that there is inconsistency between when singleTapHandler and doubleTapHandler when is fired. For example adding console.logs:

    const singleTapHandler = useAnimatedGestureHandler<
      GestureEvent<TapGestureHandlerEventPayload>
    >({
      onActive: () => {
        console.log('singleTapHandler')
        if (controlViewOpacity.value === 0) {
          controlViewOpacity.value = withTiming(1, controlAnimteConfig);
          setControlTimeout();
        } else {
          controlViewOpacity.value = withTiming(0, controlAnimteConfig);
        }
      },
    });

    const doubleTapHandler = useAnimatedGestureHandler<
      GestureEvent<TapGestureHandlerEventPayload>,
      {
        isAlive: boolean;
      }
    >({
      onStart: ({ x }, ctx) => {
        console.log('doubleTapHandler, onStart')
        if (x > leftDoubleTapBoundary && x < rightDoubleTapBoundary) {
          ctx.isAlive = false;
          return;
        } else {
          ctx.isAlive = true;
        }
      },
      onActive: ({ x, y, numberOfPointers }, ctx) => {
        console.log('doubleTapHandler, onActive')
        if (numberOfPointers !== 1) return;
        if (!ctx.isAlive) {
          resetControlTimeout();
          if (controlViewOpacity.value === 0) {
            showControlAnimation();
            return;
          }
        }

        if (x < leftDoubleTapBoundary) {
          doubleLeftOpacity.value = 1;
          rippleLeft.current?.onPress({ x, y });
          runOnJS(seekByStep)(true);
          return;
        }

        if (x > rightDoubleTapBoundary) {
          doubleRightOpacity.value = 1;
          rippleRight.current?.onPress({
            x: x - rightDoubleTapBoundary,
            y,
          });
          runOnJS(seekByStep)(false);

          return;
        }
      },
    });

If I tap the play button once:

  1. singleTapHandler
  2. doubleTapHandler, onStart

This is only one scenario I've observed but "doubleTapHandler, onStart'" is never logged out in all cases so you can never go 10s forward or backwards. Strangely this problem does not appear on the iOS simulator so my suspicion is that it might be to do with react-native-gesture-handler and its Android integration but I can't be sure as this module uses the v1 and the v2 changes are substantial (I noticed that you have v2 as on your todo).

Long story short have you seen this issue before and do you know what might be causing it?

alantoa commented 2 years ago

Hi, @khlling ! I know this problem, I forgot to update this, I will fix it later.

On android, react-native-gesture-handle needs to wrap the Animate.View to change the transparency.

(But It's already late at night here or I'll fix this.:)

khlling commented 2 years ago

Hi @alantoa,

Thanks for the quick response! Look forward to the update. I have a couple of contributions that I think would help with extensibility of the module, which I will PR soon. :)

alantoa commented 2 years ago

@khlling Hi, thank you! Waiting for your PRs

alantoa commented 2 years ago

@khlling Hi, I have updated the code, fix this bug. Now you can try it! And I'm using m1 pro chip, so I have to upgrade example android sdk etc.(Performance testing suggests in production)

khlling commented 2 years ago

@alantoa I also have a m1 pro. Just tried it out, looks like it's working as expected! 👍

khlling commented 2 years ago

@khlling Hi, thank you! Waiting for your PRs

What do you use for your semantic git commit messages? I'll follow your style. Do you use a plugin?

alantoa commented 2 years ago

@khlling Hi! Preferably the Angular commit. Thank you!

khlling commented 2 years ago

Hi @alantoa, can you provide me collaborator access or allow general creation of branches/pushing access please. Thanls!

alantoa commented 2 years ago

@khlling Hi, I have added, you check it!