Hello, and now here is my second waste of code for the community :), but at this time it should come in a bit handy for hobby developers. First, I only wanted to increase my programming experience. On second thought I needed something for my projects in the future. And I needed a tag editor for the ID3v1.1 standard. My tag editor class reduces editing these information to a minimum, and the only project about ID3v1 tags I found for C# on this server was a project which only is able to read these information.
Using the code
There are two classes: the tagger class
Tagger and a small database for the genres
GenreDB. The class
Tagger has eleven public properties and one public method. Let's begin with the properties:
bool hasTag - indicates if the file has a tag. When you save the file it records if you want to have a tag in the future.
string Title - sets or reads the title. If the size is over 30 characters, it throws a
string Artist - sets or reads the artist. If the size is over 30 characters, it throws a
string Album - sets or reads the album. If the size is over 30 characters, it throws a
string Year - sets or reads the year. If the size is over 4 characters, it throws a
string Comment - sets or reads the comment. If the size is over 28 characters, it throws a
string TitleNumber - sets or reads the title number. If the value is greater than 255 or smaller than 0, or the value is not a number, it throws a
string GenreID - sets or reads the genre ID. If the value is greater than 255 or smaller than 0, or the value is not a number, it throws a
string GenreName - reads the
GenreID and returns the genre name as string. If there's an ID over 147, it returns an empty string.
string FullFilePath - returns the full path of the used file.
long FileSize - returns the actual file size.
And the single public method in this party is to write/update the file:
And now to the mentioned database for the genre (
GenreDB). It has one static property and one static method. The use of it is very simple. First the static property:
static string GenreList - In this list, there are all genres specified in the ID3v1 standard. There are also the Winamp extensions in it. The order is like what is specified. So when you use this property like
GenreDB.GenreList, you'll get the string "Dance". When you write
GenreDB.GenreList (one of the Winamp Extensions), you'll get the string "Avantgarde" (you'll find the order here in German, and in English here). Or you simply use the
GenreList to enumerate the list with a
foreach block or something.
The next is the method:
static string GetGenreID(string genre) - It has a
string in its arguments. When you need the proper ID for a genre, you can try this method. If it doesn't find the proper element in the list, it will return an empty string.
Tagger myTagger = new Tagger("C:\\test.mp3");
myTagger.Artist = "me";
myTagger.Album = "i dont know";
You see, the use of it is very simple, but when you want to write the file, make sure
true, otherwise it won't write your edits.
Point of interest
I'm not a starter, but I'm far away from an experienced programmer, so I learned many things. For example, I'm now able to read out of files byte by byte, and convert these bytes into the information I want. But I don't want to bother you, and want to let you use my code :). Have fun with it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.