by saulo » Tue Mar 11, 2008 3:47 pm
hi guys, i have the answer, if you need, there it is:
test1.php (here show the info of mp3)
<?php
require_once('getid3/getid3/getid3.php');
//$filename="musica/yoursong.mp3";
// include getID3() library (can be in a different directory if full path is specified)
// Initialize getID3 engine
$getID3 = new getID3;
// Analyze file and store returned data in $ThisFileInfo
$ThisFileInfo = $getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
// Optional: copies data from all subarrays of [tags] into [comments] so
// metadata is all available in one location for all tag formats
// metainformation is always available under [tags] even if this is not called
getid3_lib::CopyTagsToComments($ThisFileInfo);
$picture = @$ThisFileInfo['id3v2']['APIC'][0]['data']; // binary image data
echo $picture;
// Output desired information in whatever format you want
// Note: all entries in [comments] or [tags] are arrays of strings
// See structure.txt for information on what information is available where
// or check out the output of /demos/demo.browse.php for a particular file
// to see the full detail of what information is returned where in the array
echo @$ThisFileInfo['comments_html']['artist'][0]."<br>"; // artist from any/all available tag formats
echo @$ThisFileInfo['tags']['id3v2']['title'][0]."<br>"; // title from ID3v2
echo @$ThisFileInfo['audio']['bitrate']."<br>"; // audio bitrate
echo @$ThisFileInfo['playtime_string']."<br>"; // playtime in minutes:seconds, formatted string
echo "<img src='cover.php' width='200'>";
?>
and cover.php (here show the binary data)
<?
require_once('getid3/getid3/getid3.php');
$getID3 = new getID3;
#$getID3->option_tag_id3v2 = true; # Don't know what this does yet
$getID3->analyze("musica/01-maroon_5-if_i_never_see_your_face_again.mp3");
if (isset($getID3->info['id3v2']['APIC'][0]['data'])) {
$cover = $getID3->info['id3v2']['APIC'][0]['data'];
} elseif (isset($getID3->info['id3v2']['PIC'][0]['data'])) {
$cover = $getID3->info['id3v2']['PIC'][0]['data'];
} else {
$cover = null;
}
if (isset($getID3->info['id3v2']['APIC'][0]['image_mime'])) {
$mimetype = $getID3->info['id3v2']['APIC'][0]['image_mime'];
} else {
$mimetype = 'image/jpeg'; // or null; depends on your needs
}
if (!is_null($cover)) {
// Send file
header("Content-Type: " . $mimetype);
if (isset($getID3->info['id3v2']['APIC'][0]['image_bytes'])) {
header("Content-Length: " . $getID3->info['id3v2']['APIC'][0]['image_bytes']);
}
echo($cover);
}
?>
nice day!