0

As I mentioned in the title I am using react-player. My goal is to set start time for video. Currently my component looks like this:

const VideoPlayer = () => {
    const [config] = useState<ConfigProps>({
        url: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
        testStartFrom: 30
    });
    const [isReady, setIsReady] = useState(false);
    const playerRef = useRef(null);

    const onReady = useCallback(() => {
        if (!isReady) {
          playerRef.current.seekTo(config.testStartFrom ?? 0, "seconds");
          setIsReady(true);
        }
      }, [isReady]);

    return (
        <ReactPlayer
            ref={playerRef}
            url={config.url}
            onReady={onReady}
            controls
        />
    )
}

Almost everything is good, the video starts from 30 seconds, but I got double network request to achieve that. Network looks like this (The first request is from 0s, second is from 30s):

My question is: There is a way to achieve setting start time with single request?

enter image description here

enter image description here

enter image description here

huhWell
  • 89
  • 1
  • 2
  • 6

0 Answers0