NAME

Tag - Module for reading tags of MP3 audio files

SYNOPSIS

use Tag;
$mp3 = MP3::Tag->new($filename);
$mp3->getTags;

if (exists $mp3->{ID3v1}) {
  $id3v1 = $mp3->{ID3v1};
  print $id3v1->song;
  ...
}

if (exists $mp3->{ID3v2}) {
  ($name, $info) = $mp3->{ID3v2}->getFrame("TIT2");
  ...
}

$mp3->close();

AUTHOR

Thomas Geffert, thg@users.sourceforge.net

DESCRIPTION

Tag is a wrapper module to read different tags of mp3 files. It provides an easy way to access the functions of seperate moduls which do the handling of reading/writing the tags itself.

At the moment MP3::Tag::ID3v1 and MP3::Tag::ID3v2 are supported.

!! As this is only a beta version, it is very likely that the design !! of this wrapper module will change soon !!

new()
$mp3 = MP3::Tag->new($filename);

Creates a mp3-object, which can be used to retrieve/set different tags.

getTags()
@tags = $mp3->getTags;

Checks which tags can be found in the mp3-object. It returns a list @tags which contains strings identifying the found tags.

Each found tag can be accessed then with $mp3->{tagname} .

Use the information found in MP3::Tag::ID3v1 and MP3::Tag::ID3v2 to see what you can do with the tags.

newTag()
$tag = $mp3->newTag($tagname);

Creates a new tag of the given type $tagname. You can access it then with $mp3->{$tagname}. At the moment ID3v1 and ID3v2 are supported as tagname.

Returns an tag-object: $mp3->{$tagname}.

close()
$mp3->close;

You can use close() to explicitly close a file. Normally this is done automatically by the module, so that you don't need to do this.

genres()
$allgenres = $mp3->genres;
$genreName = $mp3->genres($genreID);
$genreID   = $mp3->genres($genreName);

Returns a list of all genres (reference to an array), or the according name or id to a given id or name.

This function is only a shortcut to MP3::Tag::ID3v1->genres.

This can be also called as MP3::Tag->genres;

autoinfo()
($song, $track, $artist, $album) = $mp3->autoinfo();
$info_hashref = $mp3->autoinfo();

autoinfo() returns information about the song name, song number, artist number and album name. It can get this information from an ID3v1-tag, an ID3v2-tag and from the filename itself.

It will as default first try to find a ID3v2-tag to get this information. If this cannot be found it tries to find a ID3v1-tag and if this is not present either, it will use the filename to retrieve the information.

You can change the order of this with the config() command.

autoinfo() returns an array with the information or a hashref. The hash then has the keys song, track, artist, album where the information is stored.

config
MP3::Tag->config("item", options, ...);

Possible items are:

* autoinfo

Configure the order in which ID3v1-, ID3v2-tag and filename are used
by autoinfo.  options can be "ID3v1","ID3v2","filename". The order
in which they are given to config also sets the order how they are
used by autoinfo. If an option is not present, it will not be used
by auotinfo.

$mp3->config("autoinfo","ID3v1","ID3v2","filename");

  sets the order to check first ID3v1, then ID3v2 and last the
  Filename

$mp3->config("autoinfo","ID3v1","filename","ID3v2");

  sets the order to check first ID3v1, then the Filename and last
  ID3v2. As the filename will be always present ID3v2 will be
  checked never.

$mp3->config("autoinfo","ID3v1","ID3v2");

  sets the order to check first ID3v1, then ID3v2. The filename will
  be never used.

* Later this will be used probably to configure more things.

SEE ALSO

MP3::Tag::ID3v1, MP3::Tag::ID3v2, MP3::Tag::File

1 POD Error

The following errors were encountered while parsing the POD:

Around line 292:

You forgot a '=back' before '=head1'