Skip to content

Instantly share code, notes, and snippets.

@robesris
Created May 18, 2010 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robesris/404416 to your computer and use it in GitHub Desktop.
Save robesris/404416 to your computer and use it in GitHub Desktop.
<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($file)) {
echo "<h1>$file</h1>";
$album = opendir($file);
while (false !== ($song = readdir($album))) {
$info = pathinfo($song);
if ($info['extension'] == "mp3" || $info['extension'] == "ogg") {
echo "<div>$song<audio controls='controls' src=\"$file/$song\">";
echo "</audio></div>";
}
}
}
}
}
closedir($handle);
}
?>
@robesris
Copy link
Author

Really simple php script for listing directories of mp3s or ogg files as albums and displaying them with audio controls using HTML5 audio tag. Only Chrome seems to have native mp3 support right now.

@robesris
Copy link
Author

Took out one line that had an unused variable assignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment