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

Events #278

Open
midoalawieh opened this issue Jul 16, 2024 · 2 comments
Open

Events #278

midoalawieh opened this issue Jul 16, 2024 · 2 comments

Comments

@midoalawieh
Copy link

Hello, How can I use events? I am trying to do this

<Vimeo video="3718294" autoplay onProgress={console.log("hey")}/>

but the even is not getting triggered

@tomlagier
Copy link

Event callbacks take a function that is called. So replace console.log("hey") with () => console.log("hey").

@afu-codemonday
Copy link

I was try onPlay, onPlaying all event is not working but I found work around here my code try this

  const [player, setPlayer] = useState<any>(undefined)
  const isMount = useRef(false)

  useEffect(() => {
    if (player && !isMount.current) {
      try {
        player.on('play', () => {
          onPlay && onPlay()
        })
        player.on('pause', () => { // pause and finish
          onPauseOrEnd && onPauseOrEnd()
        })
        onPlayerReady && onPlayerReady()
        isMount.current = true
      } catch (e) {
        console.log('fail to load player event e:', e)
      }
    }
  }, [player])
  
  return (
     <Vimeo
        onReady={setPlayer}
        video={videoId}
        ...
     />
  )

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

3 participants