Google

PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Synopsis

Read the tag from a file or create and Mp3Tag instance for saving tag to mp3 file later:

tag = Mp3Tag.new(filename)

Examining tags:

tag.songname
tag.artist
tag.album
tag.year
tag.comment
tag.tracknum
tag.genre_id
tag.genre

Setting tags:

tag.songname = "My Song"
tag.artist = "Me"
tag.album = "My Album"
tag.year = "2001"
tag.comment = "No Comment"
tag.tracknum = 3

tag.genre_id = 23
tag.genre = "Drum Solo"

genre_id's should exist in Mp3Tag::Genres. Elements in Mp3Tag::Genres can be assigned using tag.genre= and the id will be looked up automatically.

Saving tag to mp3:

tag.commit

Checking if a file has a tag:

Mp3Tag.hastag?(filename)

Class Methods

Mp3Tag.new(path)

Creates a new Mp3Tag object for the file give by path.

Mp3Tag.hastag?(filename)

Tests if filename has a ID3V1.0 or ID3V1.1 tag. Returns a boolean values giving the result of the test.

Mp3Tag.removetag(filename)

Removes an ID3v1 tag from the MP3 file filename

Instance Methods

songname
artist
album
comment

Return the song name, artist, album, or comment from the tag as a String object. Will return empty strings if file did not have a tag.

tracknum

Returns the track number from the tag. Will return 0 if the track number was not set in the tag when loaded, or if the file had no tag.

year

Returns the year from the tag. Will return 0 if the file had no tag.

genre_id

Return the id number of the genre from the tag. Will return 255 if the file had no tag.

genre

Returns the genre name. Will return "Unknown" if the file had no tag or the genre id was not in Mp3Tag::Genres

path

Returns the full path name of the MP3 file.

filename

Returns the filename without the directory part of the MP3 File.

songname=(txt)
artist=(txt)
album=(txt)
comment=(txt)

Sets the song name, atist, album, or comment for the tag to txt. txt should be a String object.

tracknum=(num)

Sets the track number for the tag. Only values in the range (0..255) are allowed.

year=(num)

Sets the year for the tag. Should be a four digit number.

genre_id=(num)

Sets the the genre id for the tag. Only values in the range (0..255) are allowed.

genre=(txt)

Sets the genre id for the tag to the index of txt in Mp3Tag::Genres. The genre id will be set to 255 if txt is not found in the list.

commit

Saves the tag to the MP3 file. Will overwrite any existing tag.