A simple Vimeo player component built with React hooks
Better documentation coming soon!
Currently this Vimeo player accepts the following props:
- id: number (video id from vimeo)
- width: string (defaults to '500px')
- height: string (defaults to '')
- controls: boolean (whether to display Vimeo controls; defaults to false)
- autoplay: boolean (whether to autoplay; defaults to false)
- muted: boolean (whether to initialize on mute defaults to false)
- play: boolean (set to true to play video; set to false to pause the video; defaults to false)
- getTime: boolean (set to true to get timestamp; defaults to false)
- setTime: function (your function for handling the timestamp after getting it from Vimeo)
importReact,{useState,useCallback}from'react'importPlayerfrom'll-vimeo-player'exportdefaultfunctionExample(){const[isPlaying,setIsPlaying]=useState(false)const[getTime,setGetTime]=useState(false)const[time,setTime]=useState(null)constgetTimestamp=useCallback((secs)=>{setTime(secs)setGetTime(false)console.log(time)},[time])return(<div><Playerid={371234010}play={play}getTime={getTime}setTime={getTimestamp}/><buttononClick={()=>setPlay(true)}>play</button><buttononClick={()=>setPlay(false)}>pause</button><buttononClick={()=>setGetTime(true)}>get timestamp</button></div>)}