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

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

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 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