Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

268
Visualizações
how to work html video auto play with sound?

I added the html video code to the mute/unmute button. Here's my conflict, I tried to add my video to play automatically with the sound and someone muted the video to give some solution (when the sound is muted by clicking the mute button and the video should always be playing), but when is the play video sound Not playing automatically, then click the mute button Sound is playing, does anyone have a solution?

Thanks

here the code

var video = document.getElementById("myVideo");
var btn = document.getElementById("myBtn");

function myFunction() {
    btn.innerHTML = video.muted ? "Unmute":'Mute';
    video.muted = !video.muted;
}
<div class="content">

  <button id="myBtn" onclick="myFunction()">Mute</button>
</div>

<video autoplay muted loop id="myVideo">
  <source src="https://www.w3schools.com/tags/movie.mp4" type="video/mp4">
  Your browser does not support HTML5 video.
</video>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Perhaps this is closer to what you want? It also might help to add the controls attribute as this is generally better practice. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#attr-controls

var video = document.getElementById("myVideo");
var btn = document.getElementById("myBtn");

function myFunction() {
    video.muted = !video.muted;
    btn.innerHTML = video.muted ? "Unmute":'Mute';
}
<video autoplay loop id="myVideo">
  <source src="https://www.w3schools.com/tags/movie.mp4" type="video/mp4">
  Your browser does not support HTML5 video.
</video>

<div class="content">

  <button id="myBtn" onclick="myFunction()">Toggle Mute</button>
</div>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda