0

我有一个按钮,当长按时,它会开始录制视频。只要手指按住视频,视频就会录制,当您抬起手指时,视频就会停止录制。

现在,当我添加一个平移响应器来查找人的手指位置时,我在录制时移动手指,录制会自动停止,而无需我抬起手指。

知道为什么会这样吗?

这是我的平移响应器功能:

const panResponder = React.useRef(
    PanResponder.create({
      onMoveShouldSetPanResponder: (evt, gestureState) => true,
  
      onPanResponderMove: (evt, gestureState) => {
      
        console.log(gestureState);
      },
      
    }),
  ).current;

这是我在长按上的录音功能:

const startRecord = async () => {
    setRecording(true);
    growIn();

    if (cameraRef.current) {
      setRecording(true);
      const recordedVideo = await cameraRef.current.recordAsync();

      setVideo(recordedVideo);
    }
  };

这是我渲染的组件:

<Container {...panResponder.panHandlers}>
            <CircleWrapper>
              {recording == true && (
                <Animated.View>
                  <ImageIconContainer onPress={() => console.log('Yoooo')}>
                    <ImageIcon fill={'white'} height={30} width={30} />
                  </ImageIconContainer>
                </Animated.View>
              )}
              <Animated.View style={[styles.box]}>
                <Circle
                  activeOpacity={0.8}
                  style={animatedStyles}
                  onPress={handlePhoto}
                  onLongPress={startRecord}
                  onPressOut={stopRecord}
                  delayLongPress={100}
                  hitSlop={{ top: 50, bottom: 50, left: 200, right: 200 }}>
                  {!recording && (
                    <ImageIconContainer onPress={pickImage}>
                      <ImageIcon fill={'white'} height={30} width={30} />
                    </ImageIconContainer>
                  )}

                  <Animated.View style={fadeInStyle}>
                    <CircleBackground />
                  </Animated.View>
                </Circle>
              </Animated.View>
            </CircleWrapper>
          
    </Container>
4

0 回答 0