1
我正在使用此代碼獲取MP3文件的ID3信息。從MP3獲取專輯藝術PHP
<?php
class CMP3File {
var $title;var $artist;var $album;var $year;var $comment;var $genre;
function getid3 ($file) {
if (file_exists($file)) {
$id_start=filesize($file)-128;
$fp=fopen($file,"r");
fseek($fp,$id_start);
$tag=fread($fp,3);
if ($tag == "TAG") {
$this->title=fread($fp,30);
$this->artist=fread($fp,30);
$this->album=fread($fp,30);
$this->year=fread($fp,4);
$this->comment=fread($fp,30);
$this->genre=fread($fp,1);
fclose($fp);
return true;
} else {
fclose($fp);
return false;
}
} else { return false; }
}
}
?>
我然後使用此代碼來調用它。
include ("CMP3File.php");
$filename="music_file.mp3";
$mp3file=new CMP3File;
$mp3file->getid3($filename);
echo "Title: $mp3file->title<br>\n";
echo "Artist: $mp3file->artist<br>\n";
echo "Album: $mp3file->album<br>\n";
echo "Year: $mp3file->year<br>\n";
echo "Comment: $mp3file->comment<br>\n";
echo "Genre: " . Ord($mp3file->genre) . "<br>\n";
有沒有辦法讓專輯藝術作爲圖像獲取和迴應出來?
他發佈了他試過的代碼,並且想知道如何包含封面圖片。那太局部化了? – DanMan 2014-02-01 15:06:48