Created
November 22, 2014 02:32
-
-
Save appnus/490317ab8072a99aa606 to your computer and use it in GitHub Desktop.
Stream MP3 Songs using PHP
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 header("Content-Type: audio/mpeg"); | |
$playlist = glob("*.mp3"); | |
shuffle($playlist); | |
foreach ($playlist as $song) { | |
$file = fopen($song, "r"); | |
while (($buffer = fgets($file, 1024)) !== false) { | |
echo $buffer; | |
flush(); | |
usleep(5000); | |
} | |
fclose($file); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment