Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
486 views
in Technique[技术] by (71.8m points)

react native - Trying to disable video when navigating away from the page

I have following code and I think unloadSync() is causing an error:

useFocusEffect(
    React.useCallback(() => {
      ShowVideo(true);

      return () => {
        videoRef.current?.unloadAsync()
        .catch(err => console.debug('Error unloading video player', err));
        ShowVideo(false);
      };
    }, [])
  );


{shouldShowVideo &&
      isNotNullUndefinedZero(exercise) &&
      (
          <Video
            ref={videoElementRef}
            style={styles.videoElement}
            source={{ uri: list.videoURL }}
            rate={1.0}
            volume={1.0}
            isMuted={false}
            resizeMode="cover"
            shouldPlay
            isLooping
          />

It shows the video fine but when I navigate away from that page it throws an error:

Error unloading video player [Error: Invalid view returned from registry, expecting ABI39_0_0EXVideo, got: (null)]

Can I somehow remove source from the video using the ref hook on changing the page?

question from:https://stackoverflow.com/questions/65946264/trying-to-disable-video-when-navigating-away-from-the-page

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...