ID3 tag in VB.Net

We don't share programs here, we share knowledge.
If you're having problems with a piece of code, then we'll be glad to help.
 
Oooh
Guess I should have realised that.... sorry

It's just that I don't know where to start.
I've found an example for .Net but i can't get it to work.

Maybe some tips to get me started?
 
Check out Dunkan McKensie's coding 4 Fun Column on MSDN his first article was on a media player he had written, which reads ID3Tags...

Or as mentioned by Derek you can use the Windows Media 9 SDK, which also provides the functionality but thought I would mention the above column as it is a nice article.
 
I'm currently writting a small API for that, but i'm having some problems with the bytes manipulation.
Just some piece of infomation, the ID3 ver.1 it's very easy since the information has a characters limit per field and it's alsways written at the end of the mp3 file, starts at a specific number of bytes from the end. But the version 2 has some problems since there is no limit for the number of characters for each field, and also is written almost at the start of the file,
Here the problems are two
First of all you have to increase the size of the file which i don't how to do in VB. And second you have to find the specific charater which marks the end of the ID3v2, which until now i haven't been able to find.
But the main problem is that you have to increase the size of the file starting in a specific byte of the file.
Any ideas anyone.. let me know.

Note: The only method i've considered is to read the whole file and then write it again which is not the best since the file can be very long like 100MBs which it wont be good to read it in the memory.
 
Well, using the SDK seems to be the easiest way but it doesn't work on all computers seems like you have to have the latest media player installed.
 
*sigh* just look at the code and figure out the bits you want. Look at the methods that interet you, copy them into your own classes and alter them if needed.
 
OK i wrote a litle part of code to help,
this will read any ID3v1.
and will put the fields in the variables txttitle etc.
Code:
        Imports System.IO
        Dim mp As FileStream
        Dim Title(30) As Byte
        Dim Artist(30) As Byte
        Dim Album(30) As Byte
        Dim Year(4) As Byte
        Dim Comments(30) As Byte
        mp = New FileStream("D:\mpdok.mp3", FileMode.Open)
        mp.Seek(-125, SeekOrigin.End)
        mp.Read(Title, 0, 30)
        mp.Seek(-95, SeekOrigin.End)
        mp.Read(Artist, 0, 30)
        mp.Seek(-65, SeekOrigin.End)
        mp.Read(Album, 0, 30)
        mp.Seek(-35, SeekOrigin.End)
        mp.Read(Year, 0, 4)
        mp.Seek(-31, SeekOrigin.End)
        mp.Read(Comments, 0, 30)
        Dim TxtTitle As String = System.Text.Encoding.ASCII.GetString(Title)
        Dim TxtArtist As String = System.Text.Encoding.ASCII.GetString(Artist)
        Dim TxtAlbum As String = System.Text.Encoding.ASCII.GetString(Album)
        Dim TxtYear As String = System.Text.Encoding.ASCII.GetString(Year)
        Dim TextComments As String = System.Text.Encoding.ASCII.GetString(Comments)

The only thing that doesn't read is the genre which is a long story.. you can take a look on the link that explains about the ID3 genres that someone posted before.
http://www.id3.org
 
I have been trying this code for quite a while, but it always seems to return -
"Title
as opposed to
Title
(All the fields do this).

It displays OK on a msgbox, but the Quote really messes it up when I try to add it to a listbox or database.
Any help would be great, thanks.
 
Back
Top