示例#1
0
 function getid3($file)
 {
     $tit = '';
     $cmp = '';
     $alb = '';
     $com = '';
     $art = '';
     $mim = '';
     $dur = '';
     // Initialize getID3 engine
     if (file_exists($file)) {
         //after verifying the file exists,
         $getID3 = new getID3();
         // Analyze file and store returned data in $ThisFileInfo
         $ThisFileInfo = $getID3->analyze($file);
         // Optional: copies data from all subarrays of [tags] into [comments] so
         // metadata is all available in one location for all tag formats
         // meta-information is always available under [tags] even if this is not called
         getid3_lib::CopyTagsToComments($ThisFileInfo);
         // 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']['artist'][0]; // artist from any/all available tag formats
         $mim = @$ThisFileInfo['mime_type'];
         // artist from any/all available tag formats
         $dur = @$ThisFileInfo['playtime_string'];
         // play duration from any/all available tag formats
         switch (strrchr(strtolower($file), ".")) {
             case ".mp3":
                 $tit = @$ThisFileInfo['id3v2']['comments']['title'][0];
                 // artist from any/all available tag formats
                 $alb = @$ThisFileInfo['id3v2']['comments']['album'][0];
                 // artist from any/all available tag formats
                 $art = @$ThisFileInfo['id3v2']['comments']['artist'][0];
                 // artist from any/all available tag formats
                 $com = @$ThisFileInfo['id3v2']['comments']['comment'][0];
                 $cmp = @$ThisFileInfo['id3v2']['comments']['composer'][0];
                 // artist from any/all available tag formats
                 $gen = @$ThisFileInfo['id3v2']['comments']['genre'][0];
                 // artist from any/all available tag formats
                 break;
             case ".m4a":
                 $tit = @$ThisFileInfo['quicktime']['comments']['title'][0];
                 // artist from any/all available tag formats
                 $alb = @$ThisFileInfo['quicktime']['comments']['album'][0];
                 // artist from any/all available tag formats
                 $art = @$ThisFileInfo['quicktime']['comments']['artist'][0];
                 // artist from any/all available tag formats
                 $com = @$ThisFileInfo['quicktime']['comments']['comment'][0];
                 // artist from any/all available tag formats
                 $cmp = @$ThisFileInfo['quicktime']['comments']['writer'][0];
                 // artist from any/all available tag formats
                 // $gen = @$ThisFileInfo['quicktime']['comments']['genre'][0]; // artist from any/all available tag formats
                 break;
             case ".m4b":
                 $tit = @$ThisFileInfo['quicktime']['comments']['title'][0];
                 // artist from any/all available tag formats
                 $alb = @$ThisFileInfo['quicktime']['comments']['album'][0];
                 // artist from any/all available tag formats
                 $art = @$ThisFileInfo['quicktime']['comments']['artist'][0];
                 // artist from any/all available tag formats
                 $com = @$ThisFileInfo['quicktime']['comments']['comment'][0];
                 // artist from any/all available tag formats
                 $cmp = @$ThisFileInfo['quicktime']['comments']['writer'][0];
                 // artist from any/all available tag formats
                 // $gen = @$ThisFileInfo['quicktime']['comments']['genre'][0]; // artist from any/all available tag formats
                 break;
             case ".mov":
                 $tit = @$ThisFileInfo['quicktime']['comments']['title'][0];
                 // artist from any/all available tag formats
                 $alb = @$ThisFileInfo['quicktime']['comments']['album'][0];
                 // artist from any/all available tag formats
                 $art = @$ThisFileInfo['quicktime']['comments']['artist'][0];
                 // artist from any/all available tag formats
                 $com = @$ThisFileInfo['quicktime']['comments']['comment'][0];
                 // artist from any/all available tag formats
                 $cmp = @$ThisFileInfo['quicktime']['comments']['director'][0];
                 // artist from any/all available tag formats
                 // $gen = @$ThisFileInfo['quicktime']['comments']['genre'][0]; // artist from any/all available tag formats
                 break;
             case ".asf":
                 $tit = @$ThisFileInfo['asf']['comments']['title'][0];
                 // artist from any/all available tag formats
                 $alb = @$ThisFileInfo['asf']['comments']['album'][0];
                 // artist from any/all available tag formats
                 $art = @$ThisFileInfo['asf']['comments']['artist'][0];
                 // artist from any/all available tag formats
                 $com = @$ThisFileInfo['asf']['comments']['comment'][0];
                 // artist from any/all available tag formats
                 $cmp = @$ThisFileInfo['asf']['comments']['composer'][0];
                 // artist from any/all available tag formats
                 $gen = @$ThisFileInfo['asf']['comments']['genre'][0];
                 // artist from any/all available tag formats
                 break;
             case ".wma":
                 $tit = @$ThisFileInfo['asf']['comments']['title'][0];
                 // artist from any/all available tag formats
                 $alb = @$ThisFileInfo['asf']['comments']['album'][0];
                 // artist from any/all available tag formats
                 $art = @$ThisFileInfo['asf']['comments']['artist'][0];
                 // artist from any/all available tag formats
                 $com = @$ThisFileInfo['asf']['comments']['comment'][0];
                 // artist from any/all available tag formats
                 $cmp = @$ThisFileInfo['asf']['comments']['composer'][0];
                 // artist from any/all available tag formats
                 $gen = @$ThisFileInfo['asf']['comments']['genre'][0];
                 // artist from any/all available tag formats
                 break;
             default:
                 $tit = $file;
                 // artist from any/all available tag formats
         }
         // end switch
         $this->title = stripJunk($tit);
         $this->composer = stripJunk($cmp);
         $this->album = stripJunk($alb);
         $this->comment = stripJunk($com);
         $this->copyright = stripJunk($cmp);
         $this->artist = stripJunk($art);
         $this->mime_type = stripJunk($mim);
         $this->duration = stripJunk($dur);
         return true;
     } else {
         return false;
         // file doesn't exist
     }
     // end if
 }
示例#2
0
function readFrame($frameTag, $header, $ver)
{
    if ($ver == 3) {
        $lengthOffset = 6;
        $textOffset = 11;
    }
    if ($ver == 2) {
        $lengthOffset = 4;
        $textOffset = 7;
    }
    // find the tag we're looking for
    $tagStart = strpos($header, $frameTag);
    // this code only reads the first 256 bytes on larger frames
    $tagLength = ord(substr($header, $tagStart + 1 + $lengthOffset, 1));
    $textStart = $tagStart + $textOffset;
    if ($frameTag == "COMM" || $frameTag == "COM") {
        $textStart = $textStart + 4;
        $tagLength = $tagLength - 4;
    }
    $tagText = substr($header, $textStart, $tagLength - 1);
    return stripJunk($tagText);
}
示例#3
0
 function stripJunkwithsinglequote($str)
 {
     $str = stripJunk($str);
     $str = str_replace("'", "", $str);
     $str = str_replace('"', "", $str);
     return $str;
 }