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

380
Views
React: How to unmute html video by custom button

I am working on a project and came across a little issue: So, i have a video tag:

<video muted autoPlay loop src={video}>

and i just want a single custom button/control to unmute and mute the video. Am i right when i think of something using reactHooks and something like onClick={(handleChange => ??, or something like this:

    <button onClick={() => toggle(!mute)}>
        {mute ? 'Mute' : 'Unmute'}
    </button>

but i do not really know how to setup the mute function in order to control the video tag.

Can someone help me out?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I managed to solve it, this is how:

const [muted, setMuted] = useState(true);
const handleToggleMute = () => setMuted(current => !current);
                
<button onClick={handleToggleMute} className="control">Unmute</button>
about 4 years ago · Juan Pablo Isaza Report
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!