Пример #1
0
 function DeleteTags($TagFormatsToDelete)
 {
     foreach ($TagFormatsToDelete as $DeleteTagFormat) {
         $success = false;
         // overridden if tag deletion is successful
         switch ($DeleteTagFormat) {
             case 'id3v1':
                 $id3v1_writer = new getid3_write_id3v1();
                 $id3v1_writer->filename = $this->filename;
                 if (($success = $id3v1_writer->RemoveID3v1()) === false) {
                     $this->errors[] = 'RemoveID3v1() failed with message(s):<PRE><UL><LI>' . trim(implode('</LI><LI>', $id3v1_writer->errors)) . '</LI></UL></PRE>';
                 }
                 break;
             case 'id3v2':
                 $id3v2_writer = new getid3_write_id3v2();
                 $id3v2_writer->filename = $this->filename;
                 if (($success = $id3v2_writer->RemoveID3v2()) === false) {
                     $this->errors[] = 'RemoveID3v2() failed with message(s):<PRE><UL><LI>' . trim(implode('</LI><LI>', $id3v2_writer->errors)) . '</LI></UL></PRE>';
                 }
                 break;
             case 'ape':
                 $ape_writer = new getid3_write_apetag();
                 $ape_writer->filename = $this->filename;
                 if (($success = $ape_writer->DeleteAPEtag()) === false) {
                     $this->errors[] = 'DeleteAPEtag() failed with message(s):<PRE><UL><LI>' . trim(implode('</LI><LI>', $ape_writer->errors)) . '</LI></UL></PRE>';
                 }
                 break;
             case 'vorbiscomment':
                 $vorbiscomment_writer = new getid3_write_vorbiscomment();
                 $vorbiscomment_writer->filename = $this->filename;
                 if (($success = $vorbiscomment_writer->DeleteVorbisComment()) === false) {
                     $this->errors[] = 'DeleteVorbisComment() failed with message(s):<PRE><UL><LI>' . trim(implode('</LI><LI>', $vorbiscomment_writer->errors)) . '</LI></UL></PRE>';
                 }
                 break;
             case 'metaflac':
                 $metaflac_writer = new getid3_write_metaflac();
                 $metaflac_writer->filename = $this->filename;
                 if (($success = $metaflac_writer->DeleteMetaFLAC()) === false) {
                     $this->errors[] = 'DeleteMetaFLAC() failed with message(s):<PRE><UL><LI>' . trim(implode('</LI><LI>', $metaflac_writer->errors)) . '</LI></UL></PRE>';
                 }
                 break;
             case 'lyrics3':
                 $lyrics3_writer = new getid3_write_lyrics3();
                 $lyrics3_writer->filename = $this->filename;
                 if (($success = $lyrics3_writer->DeleteLyrics3()) === false) {
                     $this->errors[] = 'DeleteLyrics3() failed with message(s):<PRE><UL><LI>' . trim(implode('</LI><LI>', $lyrics3_writer->errors)) . '</LI></UL></PRE>';
                 }
                 break;
             case 'real':
                 $real_writer = new getid3_write_real();
                 $real_writer->filename = $this->filename;
                 if (($success = $real_writer->RemoveReal()) === false) {
                     $this->errors[] = 'RemoveReal() failed with message(s):<PRE><UL><LI>' . trim(implode('</LI><LI>', $real_writer->errors)) . '</LI></UL></PRE>';
                 }
                 break;
             default:
                 $this->errors[] = 'Invalid tag format to delete: "' . $tagformat . '"';
                 return false;
                 break;
         }
         if (!$success) {
             return false;
         }
     }
     return true;
 }
// | Authors: James Heinrich <infoØgetid3*org>                            |
// |          Allan Hansen <ahØartemis*dk>                                |
// +----------------------------------------------------------------------+
// | demo.write.apetag.php                                                |
// | getID3() demo file - showing how to write APEtags with getID3().     |
// +----------------------------------------------------------------------+
//
// $Id: demo.write.apetag.php,v 1.3 2006/11/16 22:11:59 ah Exp $
// Enter your filename here
$filename = '/data/getid3/test.mp3';
// Include getID3() library (can be in a different directory if full path is specified)
require_once '../getid3/getid3.php';
// Include desired writer module
require_once '../getid3/write.apetag.php';
// Instantiate desired tag class
$tw = new getid3_write_apetag($filename);
// Attempt to read current tag
if ($tw->read()) {
    print 'File contains tag already; artist is "' . $tw->comments['artist'] . '"<br>';
}
// Attempt to write new tag  -- NOTE: all values must be in UTF-8
try {
    $tw->comments['artist'] = 'getID3() Testing';
    $tw->comments['date'] = array('1960 (recorded)', '1999 (remastered)');
    $tw->write();
    print 'New tag written<br>';
} catch (Exception $e) {
    print $e->message;
}
// Attempt to remove tag
try {