Audio does not trigger event completed

0

I have a streaming.php file that prints a different audio in mp3 for each GET that is made on the file. The view is labeled audio de HTML5 that calls that PHP.

In a section of javascript, I try to trigger the event ended to refresh again to streaming.php :

var audio = document.getElementById("id");

audio.addEventListener("ended", function(){ //No se desencadena
     console.log('algo');
     audio.src = './streaming.php';

});

PHP:

readfile($path);
header("Cache-Control: no-cache, no-store, must-revalidate");
header("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: binary');
header("Content-Length: ".filesize($path));
header('Content-Disposition: attachment; filename="straming.mp3";');
header('Content-Type: audio/mp3');

I have also noticed that the audio pauses a second before ending, if I play in the view if the expected is done. I do not know how to solve this.

Thanks in advance!

    
asked by Islam Linarez 08.02.2018 в 00:02
source

0 answers