Reputation: 553
I want to call the .play() method on a cloudinary-react Video component.
I tried to put a ref onto the Video component, but when I call play on the ref it doesn't get forwarded to the video-tag.
<Video ref={this.videoPlayer} />
If I put a onClick on the component it gets forwarded to the video-tag and starts playing:
<Video onClick={(e) => e.target.play()} />
there is no interface on the video-component for playing or pausing or only no documentation.
Upvotes: 1
Views: 661
Reputation: 71
Pass the ref to the video with "innerRef" instead of "ref".
const videoRef = useRef();
function PauseVideo()
{
videoRef.current.pause();
}
return(
<AdvancedVideo
cldVid={YOUR_VIDEO}
innerRef={videoRef}
controls
/>
);
Upvotes: 0
Reputation: 497
To add controls to the video, a transformation can be added to the Cloudinary Video component. The transformation would be:
<Transformation controls="true" />
The video tag would look like this:
<Video publicId="myPublicId" fallbackContent="Your browser does not support HTML5 video tags.">
<Transformation controls="true"/>
</Video>
You can also refer to this in the Cloudinary documentation here: https://cloudinary.com/documentation/react_video_manipulation#example_3
Upvotes: 0