Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

390
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda