Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart Video #221

Open
bennik88 opened this issue Sep 20, 2022 · 1 comment
Open

Restart Video #221

bennik88 opened this issue Sep 20, 2022 · 1 comment

Comments

@bennik88
Copy link

Problem

I want to restart the video and can't find a way to make it work.

I'm trying to make an on hover video player, so as soon as you hover over the video it starts playing and when you leave the mouse the thumbnail will appear again and it starts from new as soon as you hover again.

What I've tried

Set the start prop to 0 as soon as the video is paused. But it seems to have no effect. Is this prop refreshing?
I've also tried to use the onPause prop to set the setStart state to 0.

@goto-bus-stop
Copy link
Member

The start prop is a bit unusual, changing it doesn't really do anything. It's only used when the video ID changes as well. For granular/direct control like this, you need to use the methods on the underlying @vimeo/player instance, which you can access in onReady.

const [player, setPlayer] = useState(null)

const restartVideo = useCallback(() => {
  player.setCurrentTime(0)
}, [player])

return <Vimeo onReady={setPlayer} />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants