-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Question: Ref.seekTo is not a function #1548
Comments
I had to specify the type info to get the ref to work properly. const playerRef = React.useRef<ReactPlayer>(null); Used like this: <ReactPlayer
ref={playerRef}
url={streamTrack.link}
playing={playState}
onPlay={() => announceMediaSession()}
onProgress={(state) => {
setSecondsPlayed(state.playedSeconds);
}}
onError={(error, data, hlsInstance) => {
console.log({ error, data, hlsInstance });
}}
onEnded={() => nextTrack()}
width={0}
height={0}
style={{ display: "none" }}
></ReactPlayer> |
You need to call it like this: |
I'm not using typescript :( |
Yes I've tried but same error occurs |
Same issue but with I'm using |
I tried, but still have the issue |
Try this solution |
I tried the solution describe in the comment. I needed to adapt the code a bit because I got compilation error using Here's the code for anyone interested: // main file
import dynamic from "next/dynamic";
const ReactPlayerComponent = dynamic<ReactPlayerProps>(
() => import("./ReactPlayer").then(r => r.ReactPlayerComponent),
{
ssr: false
}
);
// ReactPlayer.tsx
const ReactPlayerComponent: React.FC<ReactPlayerProps> = ({
playerRef,
}) => {
return (
<ReactPlayer
ref={playerRef}
/>
);
}; |
I am using react-player with my next.js site and am having trouble using seekTo function. It results in error saying: "playerRef.seekTo is not a function"
I tried "playerRef.current.seekTo(parseFloat(e.target.value))" as well but same error occurs
This was my code:
Even when I copy paste exact code from demo(https://github.com/cookpete/react-player/blob/master/src/demo/App.js), same error shows, I'm not sure why it happens :(
The text was updated successfully, but these errors were encountered: