2

我正在使用此代码获取 MP3 文件的 ID3 信息。

    <?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";  

有没有办法将专辑封面作为图像来获取和呼应?

4

0 回答 0