note 41265 modified in function.fread by aidan
| From: | aidan@php.net | Date: | Thu, 01 Jul 2004 08:43:01 +0000 |
| Subject: | note 41265 modified in function.fread by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72237@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.
<?php
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>";
}
}
?>
--was--
//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>";
}
}
http://php.net/manual/en/function.fread.php