samedi 4 juillet 2015

Using PHP to play sound

my php code to fetch all sound files, random way, in a folder is this:

$files = glob("audio/*.mp3");
$random = $files[array_rand($files)];

and to play them i use:

<audio src="<?php echo $random; ?>" width="400" height="200" controls></audio>

What i want is to play the sound files pressing a HTML button tag and not seeing the default HTML5 audio player. Just like Spotify or similar.

I tried making it with button onclick="function()" but with javascript wich is a client language i don't know a way to loop all files in my folder, just like i did with the php code above.

Any ideas? Many thanks...




Aucun commentaire:

Enregistrer un commentaire