note 41265 added to function.fread
| From: | AndriErebara at rn2 dot php dot net | Date: | Sun, 04 Apr 2004 23:01:27 +0000 |
| Subject: | note 41265 added to function.fread | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67634@lists.php.net to get a copy of this message | ||
//I've found this function useful to generate html pages of mp3 info for the files I have
//Maybe you'll find this useful too. Use it as you may see fit.
//I've removed genre support, because that made this code too long.
//Also, this was meant for windows, not linux. Maybe you want to modify it a bit.
function id31_read($fname,$retf = 0) {
if (($file = fopen("$fname", "rb", FALSE))!==FALSE) {
fseek($file, -128, SEEK_END);
$signature = fread($file, 3);
if ($signature!=="TAG") {
return("<b>$fname</b> is not a valid MP3
file!<br>");
}
fseek($file, -125, SEEK_END);
$got_it = fread($file, 122);
$start = 0;
$title = substr($got_it, $start, 30);
$start += 30;
$artist = substr($got_it, $start, 30);
$start += 30;
$album = substr($got_it, $start, 30);
$start += 30;
$year = substr($got_it, $start, 4);
$start += 4;
$comment = substr($got_it, $start, 28);
//////// DON'T USE, UNLESS YOU WORK THIS AROUND :(
// fseek($file, -2, SEEK_END);
// $track = ord(fread($file, 1));
// $track = hexdec("$track");
fseek($file, -1, SEEK_END);
$genre = ord(fread($file, 1));
fclose($file);
//if retf=true returns formatted output
if ($retf==1) {
return("<br>Title: <b>$title</b> <br>Artist:
<b>$artist</b> <br>Album: <b>$album</b> <br>Year:
<b>$year</b><br>Genre: <b>$genre</b> <br>Comment:
<b>$comment</b><br>");
} else {
$hi = array($title, $artist, $album, $year, $genre, $comment);
return($hi);
};
} else {
return "<b>$fname</b> wasn't even opened!<br>";
}
}
----
Manual Page -- http://www.php.net/manual/en/function.fread.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41265
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41265&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41265&report=yes
Search -- http://master.php.net/manage/user-notes.php