I want to create an easy shuffle audioplayer based on HTML 5 and PHP. I have 4 different sound files (length of 1 second each file).
My aim is to change the sound file randomly, but currently I need to reload the page before the next file plays.
<?php
$audioFile1 = '<source src="path/SoundFile1.wav" type="audio/mpeg">';
$audioFile2 = '<source src="path/SoundFile2.wav" type="audio/mpeg">';
$audioFile3 = '<source src="path/SoundFile3.wav" type="audio/mpeg">';
$audioFile4 = '<source src="path/SoundFile4.wav" type="audio/mpeg">';
$audioFiles = array( $audioFile1, $audioFile2, $audioFile3, $audioFile4 );
shuffle( $audioFiles );
?>
<audio controls class="iru-tiny-player" data-title="Shuffle">
<?php print $audioFiles[0]; ?>
</audio>
Is there a way to shuffle the next file after ending the current file ?