itsnubix / react-native-video-controls

A React Native video component with controls
MIT License
639 stars 527 forks source link

paused prop bug #256

Open alpgokcek opened 1 year ago

alpgokcek commented 1 year ago

Paused Prop Bug

Hi, There is a problem with the paused prop. It would we great to fix this issue in the next release 😁


Use case

We have a screen with a video on top and input boxes where users can enter title and description of their video at the bottom.


Bug:

When we pass 'paused' as true, the video does not automatically play as expected. However, if the user presses play and then presses on an input box, or enters/exits fullscreen the video pauses. Whereas if we pass 'paused' as false, this does not occur.


How I fixed it currently:

I've passed the handleTogglePlayPause function to onLoad and created a ref. On handleTogglePlayPause function, I've called the togglePlayPause method to pause the video.


ref and handleTogglePlayPause method:

const playerRef = useRef();
const handleTogglePlayPause = () => {
    playerRef?.current?.methods?.togglePlayPause();
};

VideoControlsVideoPlayer props:

<VideoControlsVideoPlayer
          ref={playerRef}
          poster={getThumbnail()}
          source={{
            uri: getVideoURI(),
          }}
          style={styles.video}
          toggleResizeModeOnFullscreen={false}
          disableVolume
          disableBack
          ignoreSilentSwitch="ignore"
          showOnStart={true}
          onLoad={handleTogglePlayPause}
        />