score:3

Accepted answer

you are not setting the isplaying to true when video starts.

here is how you can do it.

 <reactplayer
        url="https://www.youtube.com/watch?v=5djf0c3dybg"
        playing={isplaying}
        onstart={() => setisplaying(true)}
        onpause={() => setisplaying(false)}
        onended={() => setisplaying(false)}
        volume={1}
        width="50vw"
        height="50vh"
      />

you can check it here as well. https://codesandbox.io/s/pause-de-video-forked-9788g?file=/src/player.js

score:1

@saksh's answer won't work if you pause the video and resume again. i got the following from this comment by the maintainer of the react-player library: https://github.com/cookpete/react-player/issues/1152#issuecomment-767666288

 <reactplayer
        url="https://www.youtube.com/watch?v=5djf0c3dybg"
        playing={isplaying}
        onplay={() => setisplaying(true)}
        onpause={() => setisplaying(false)}
        volume={1}
        width="50vw"
        height="50vh"
      />

see https://codesandbox.io/s/pause-de-video-forked-qb685?file=/src/player.js


Related Query

More Query from same tag