|
发表于 2003-6-25 20:24:49
|
|阅读模式
来自 中国北京
见:
http://im286.net/viewthread.php?tid=239831
- <?php
- /**********
- | +---------------------------------------------------
- | CLASS NAME: GetTag
- | +---------------------------------------------------
- | Author: Arvan [E-mail:Arvan@5n9.com QQ:8817776]
- | Create date: 2003-6-25
- | Note:
- | using for getting MP3Tag.
- | +---------------------------------------------------
- | Warning: Genre could be fetched, but hard to sort
- | +---------------------------------------------------
- **********/
- class GetTag{
- var $filename;
- var $fd;
- var $debug;
- function GetTag($filename){
- $this->filename = $filename;
- $fd = fopen($filename, "r");
- $this->fd = $fd;
- @fseek($fd, -128, SEEK_END);
- $Tag = fread($fd, 3);
- if($Tag=="TAG"){
- $this->debug = true;
- }
- }
- function GetSongName(){
- $fd = $this->fd;
- @fseek($fd, -125, SEEK_END);
- return fread($fd, 30);
- if (!$debug){
- return "UNKNOWS";
- }
- }
- function GetArtist(){
- $fd = $this->fd;
- @fseek($fd, -95, SEEK_END);
- return fread($fd, 30);
- if (!$debug){
- return "UNKNOWS";
- }
- }
- function GetAlbum(){
- $fd = $this->fd;
- @fseek($fd, -65, SEEK_END);
- return fread($fd, 30);
- if (!$debug){
- return "UNKNOWS";
- }
- }
- function GetYear(){
- $fd = $this->fd;
- @fseek($fd, -35, SEEK_END);
- return fread($fd, 4);
- if (!$debug){
- return "UNKNOWS";
- }
- }
-
- function GetComment(){
- $fd = $this->fd;
- @fseek($fd, -31, SEEK_END);
- return fread($fd, 30);
- if (!$debug){
- return "UNKNOWS";
- }
- }
-
- function GetGenre(){
- $fd = $this->fd;
- @fseek($fd, -1, SEEK_END);
- $genre = fread($fd, 1);
- return $genre;
- if (!$debug){
- return "UNKNOWS";
- }
- }
- } // end class GetTag
- //example
- $t = new GetTag("NovemberRain.mp3");
- $songname = $t->getsongname(); //song's name
- $Artist = $t->GetArtist(); //Artist
- $Album = $t->GetAlbum(); //Album
- echo $songname."<br>".$Artist."<br>".$Album;
- /***
- return:
- november rain
- guns n' roses
- use your illusion
- ***/
- ?>
复制代码 |
|