- Install PHP
- Create an index.php in the folder you want to play mp3's from.
- In your terminal navigate to that folder and run:
php -S localhost:3333
- Go to http://codepen.io/clouddueling/full/atwke and your files should load.
Created
May 9, 2014 19:57
-
-
Save clouddueling/723df7bf07a7e6dc49d1 to your computer and use it in GitHub Desktop.
AngularJS FileSystem Music Player
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (isset($_GET['file'])) { | |
$filename = './' . $_GET['file']; | |
if (file_exists($filename)) { | |
header('Content-Type: audio/mpeg'); | |
header('Content-Disposition: inline;filename="' . $filename . '.mp3"'); | |
header('Content-length: ' . filesize($filename)); | |
header('Cache-Control: no-cache'); | |
header("Content-Transfer-Encoding: chunked"); | |
readfile($filename); | |
} | |
return; | |
} | |
header('Access-Control-Allow-Origin: *'); | |
header('Content-Type: application/json'); | |
$dh = opendir('./'); | |
while (false !== ($filename = readdir($dh))) { | |
if ($filename[0] == '.') { | |
continue; | |
} | |
$files[] = $filename; | |
} | |
sort($files); | |
echo json_encode($files); | |
return; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment