|
-
November 7th, 2002, 10:02 PM
#1
Reading the ID3 tag from an MP3
my research shows me that the ID3 tag is stored in the last 128 bytes of an MP3 file. i want to read out this last 128 bytes of the MP3 file into a variable so i can mess with it then write it back in. i can't figure out how to get VB.NET's binaryRead and Write objects to work even after visiting MSDN... please help. thanks
brandon
-
November 8th, 2002, 05:12 AM
#2
Never done this before so dont rate this as THE solution, there might be better ways to do this. But this worked for me. I had a form with a button1 and a textbox1 control and the following code in the event handler for the button.
Code:
Dim s As Stream = File.OpenRead("c:\Test.mp3")
Dim br As New BinaryReader(s)
Dim c As Integer
Dim sb As New System.Text.StringBuilder()
s.Seek(s.Length - 128, SeekOrigin.Begin)
For c = 1 To 128
sb.Append(Strings.Chr(br.ReadByte))
Next
TextBox1.Text = sb.ToString
The writing is as easy, just use a BinaryWriter object with the Write method instead.
/Leyan
Last edited by Athley; November 8th, 2002 at 07:20 AM.
-
November 8th, 2002, 09:37 AM
#3
http://www.csharphelp.com/archives/archive226.html Take a look here. This site has a class that is used for reading and editing id3 tags from mp3 files.
It's a bit pitty that it is in C#. But I hope you have any use of this.
WM.
What about weapons of mass construction?
-
November 8th, 2002, 10:04 AM
#4
Ahh, nice example. Shouldn't be to hard to translate into VB. It does almost exactly as I did in my example aside from that it uses a FileStream object instead of a Stream. That may increase performance a bit.
And their use of System.Text.ASCIIEncoding instead of my a bit clumbsy Strings.Chr(br.ReadByte) is more consize (as I said, it wasn't THE solution ).
/Leyan
-
November 8th, 2002, 12:05 PM
#5
Thanks guys, i'm going to be trying to re-write that C# version (because i really like it) into VB.NET code. i'll post a URL for the src when i'm done.
brandon
-
March 21st, 2003, 10:11 AM
#6
May be you can look in to http://www.id3lib.org/ for some formal information on the id3 tags.]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|