If you want to avoid using ID3 tag libraries, you could modify it to do something like only play 10% of the song, which would use the following code:
$handle = fopen($filename, 'r');
$content = fread($handle, filesize($filename));
$length = strlen($content);
if (!$session->IsLoggedIn()) {
$length = round(strlen($content) / 10); /* Change 10 to be 2 to play 50% of the song, or 5 to play 20% of the song. A value of 10 will play 10% of the song, a decent preview amount */
$content = substr($content, $length * .66 /* Start extraction 2/3 of that in; if it does turn out to be 30 seconds, it will start 20 seconds in.*/, $length);
}
header("Content-Type: {$id3_info['mime_type']}");
header("Content-Length: {$length}");
print $content;