0
My web page should play a different audio every 1 minute, without refreshing the entire page. The audio can stay in a div, but it needs to be updated every 1 minute, but the way it is, the browser always picks up the first audio played, and whenever I change the audio and save the file, the browser always picks up audio by which the page was last loaded.
In short, I need to update the audio in a div.
Follows my code:
HTML AND PHP
<?php
include("config/conn.php");
$seguntos=2; //segundos
?>
<audio id="audio" style="display:none">
<source src="sons/aero.wav" type="audio/wav" /> <!--esse arquivo é modificado faço isso manual mesmo e salvo o arquivo, mas irei automatizar isso -->
</audio>
JAVASCRIPT AUDIO FUNCTION
<script type="text/javascript">
audio = document.getElementById('audio');
function play(){
audio.play();
audio.stop();
audio.pause();
}
</script>
JAVASCRIPT FUNCTION CHECKS THE SITUATION AND THE PLAY
<script type="text/javascript">
function atualizar()
{
$.post('atualizapainel.php', function (paciente) {
$('#paciente').html('<b>' + paciente.nome_paciente + '</b><br />');
$('#local').html('<b>' + paciente.situacao + '</b><br />');
if (paciente.situacao == 'EM ATENDIMENTO') {
play();
}
paciente.situacao=1;
}, 'JSON');
}
setInterval("atualizar()", <?php echo $seguntos*30000; ?>); // Valor em milissegundos
$(function() {
atualizar();
});
</script>
This audio tag does not work with style="display:None" nor does it automatically play in Chrome and Opera. Safari does not work at all.
– user60252
pq vc denied my answer?
– user60252
It was not me. rss
– Sam
Since it wasn’t you, why do you think they did? see AP’s question
Minha pagina web deve tocar um audio diferente a cada 1 minuto, sem dar refresh na pagina inteira.
– user60252
Xiii, I think I figured it out, it was supposed to be a minute and I put 15 seconds, Aff
– user60252
I have no idea. There are people out there who are really negative.
– Sam
I got that, I feel sorry for them!
– user60252