Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

343
Views
React - how to play an html video from react component

I have a component with an html video:

interface VideoBoxProps {
  src: any
  classes?: string
  clickable?: boolean
}

export const VideoBox = ({src, classes, clickable}:VideoBoxProps) => <div className="video-wrapper" onClick={() => clickable ? src.play() : null}>
  <video width="100%" height="auto" className={classes}>
    <source src={src} type="video/mp4"/>
  </video>
  <img className="video-play-button" src={PlayButton} alt="play button"/>
</div>

I am using this component in parent component like this:

<VideoBox src={video} clickable/>

I importing and passing the video file like this:

import MyMovie from '../../assets/public/my_movie.mp4'

But, I am not sure how to play a video on clicking the .video-wrapper div? The src that I am passing is just a generated path to the file, and I am not sure how to then create a video object that I can play from any component then?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!