I'm using getid3
to get the file size and the time duration from a remote URL. getid3
does not work with remote URLs so the work-around is to download the mp3 to a temporary location, read the data and then delete it.
Code:
<?php $filename = tempnam('/tmp','getid3');
if (file_put_contents($filename,file_get_contents('http://feeds.soundcloud.com/stream/336401044-scott-johnson-27-tms-1314-pm.mp3', false, null, 0, 32768))) {
if (require_once('id3/getid3.php')) {
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($filename);
echo '<pre>'.print_r($ThisFileInfo, true).'</pre>';
}
unlink($filename);
};?>
My problem I have is that it only downloads the first 32768kb of the mp3 file and it doesn't show the correct filesize (shows as the max 32768) or the correct time duration of the file. If I increase the max size, the code will crash.
Is there a way to download either the full mp3 or find a way to get the appropriate header size without download the full file?