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

207
Visualizações
Updated Audio file is not being played when the button is pressed

Currently I'm having a web page that can play updated audio clips store locally in a folder produced from some other service. The audio that I play when button is being pressed is the previous audio clips(probably due to cache?). Unless i manually close the tab and reopen another tab.

Is it possible to let the or JS function to load the audio file every time before play

<td style="position:relative; top:1px;">
<input id="scream"
type="button"
class="btn"
onclick="play_single_sound()">
</td>

<audio src="{{url_for('static', filename='/screams/new_scream.wav')}}" id="audiotag1" autoplay="autoplay" preload="metadata"/>
<source src="/screams/new_scream.wav" type="audio/mpeg">
</audio>


<script type="text/javascript">
#FIRST METHOD
<!--                var song = document.getElementById('audiotag1')-->
<!--                function play_single_sound() {-->
<!--                    song.play();-->
<!--                }-->

#SECOND METHOD
window.play_single_sound = function() {
document.getElementById('audiotag1').play();
}
</script>

I have also attempted with loading audio as instance inside JS, as follows:

var song = new Audio ("../screams/new_scream.wav");
song.preload="auto";
song.play();

All the above methods doesn't allow me to play song clip that change dynamically in a static folder. Any advice ?

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

0

Remove autoplay attribute

<audio src="{{url_for('static', filename='/screams/new_scream.wav')}}" id="audiotag1" preload="metadata"/>
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