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 mute the audio and save the file, the browser always which page was uploaded the last time.
In short, I need to update the audio in a div.
Follow 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>
AUDIO JAVASCRIPT FUNCTION
<script type="text/javascript">
audio = document.getElementById('audio');
function play(){
audio.play();
audio.stop();
audio.pause();
}
</script>
JAVASCRIPT FUNCTION VERIFIES SITUATION AND 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>