react-vimeo icon indicating copy to clipboard operation
react-vimeo copied to clipboard

Events

Open midoalawieh opened this issue 1 year ago • 3 comments

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

midoalawieh avatar Jul 16 '24 09:07 midoalawieh

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

tomlagier avatar Jul 16 '24 17:07 tomlagier

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}
        ...
     />
  )

afu-codemonday avatar Sep 02 '24 12:09 afu-codemonday

<VimeoPlayer
  video={video}
  responsive={true}
  onPlay={() => {console.log('play');}}
  onPlaying={() => {console.log('playing');}}
/>

onPlay and onPlaying callbacks are not triggered.

1aurabrown avatar Mar 17 '25 13:03 1aurabrown