summaryrefslogtreecommitdiffstats
path: root/play/index.php
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2011-11-09 04:19:43 -0500
committerPaul Arthur <paul.arthur@flowerysong.com>2011-11-09 04:19:43 -0500
commit95cc46a3aeff03cc1c227157089063e00a78644f (patch)
tree23f08af6c1a0be5aa3ee034e2ad5f65f82414ff7 /play/index.php
parentf6ae580612460278191a2f690ad0a46049493c8d (diff)
downloadampache-95cc46a3aeff03cc1c227157089063e00a78644f.tar.gz
ampache-95cc46a3aeff03cc1c227157089063e00a78644f.tar.bz2
ampache-95cc46a3aeff03cc1c227157089063e00a78644f.zip
Some cleanup of the streaming code.
Make sure we don't overrun the Content-Length, plus some minor cosmetics.
Diffstat (limited to 'play/index.php')
-rw-r--r--play/index.php9
1 files changed, 4 insertions, 5 deletions
diff --git a/play/index.php b/play/index.php
index 0016d1ee..0fe4cf93 100644
--- a/play/index.php
+++ b/play/index.php
@@ -365,15 +365,14 @@ $bytes_streamed = 0;
// Actually do the streaming
do {
- $buf = fread($fp, 2048);
+ $buf = fread($fp, min(2048, $stream_size - $bytes_streamed));
print($buf);
$bytes_streamed += strlen($buf);
} while (!feof($fp) && (connection_status() == 0) && ($bytes_streamed < $stream_size));
-// Need to make sure enough bytes were sent. Some players (Windows Media Player)
-// won't work if specified content length is not sent.
-if($bytes_streamed < $stream_size AND (connection_status() == 0)) {
- print(str_repeat(' ',$stream_size - $bytes_streamed));
+// Need to make sure enough bytes were sent.
+if($bytes_streamed < $stream_size && (connection_status() == 0)) {
+ print(str_repeat(' ', $stream_size - $bytes_streamed));
}
// Make sure that a good chunk of the song has been played