Read/Write MP3 Info Tags 
Author Message
 Read/Write MP3 Info Tags

Does anyone have any code samples on how to read/write MP3 Info Tags???  I've
seen a few OCX controls but they charge for their use.  There has to be an
easy way to do it without paying for simple OCX controls.


Sun, 31 Dec 2000 03:00:00 GMT  
 Read/Write MP3 Info Tags

Quote:

>Does anyone have any code samples on how to read/write MP3 Info Tags???
I've
>seen a few OCX controls but they charge for their use.  There has to be an
>easy way to do it without paying for simple OCX controls.

    Download VBAmp (version 0.16, I think) from www.mp3.com or wherever else
you can find it. It includes source code, and somewhere in there is the code
to read MP3 Info Tags - I'm not sure about writing them, but with a bit of
modification you could adapt the 'reading' code to 'write'... It actually
surprised me how easy the code was - as long as you understand the structure
of an MP3 File [www.mpeg3.org], you get the hang of it very quickly.

    Anyway, hope this helps...

        Jim,



Sun, 31 Dec 2000 03:00:00 GMT  
 Read/Write MP3 Info Tags


Quote:
>Does anyone have any code samples on how to read/write MP3 Info Tags???  I've
>seen a few OCX controls but they charge for their use.  There has to be an
>easy way to do it without paying for simple OCX controls.

Below is a sample of some code I am working on.  Keep in mind that it
is very new code and only picks up the tag info from a file.  It
assumes a 140 character length at the end of the file, which could be
corrected to the true (127-128) bytes used by the tag. I create a type
structure to hold the data and dim it at the form level.

Keep in mind that this doesn't write anything to an .mp3 file.  Also
keep in mind that ID3 tag implementation is crude and should be tossed
to the wind in favor of another method, only because it has so few
fileds allowed and the fields are limited in length.  Something like
the lyrics3 tag specification should be used in place of it.  Go to
various other sites for a defination on the other tag definitions.

Deficiencies in this code are as follows:

1)  When reading of a shared read-only volume over a network the open
statement results in a path file access error.  The vbamp program
found on www.mp3.com also exhibits this same behavior.  In the
following code sample the on error resume next statement gets you past
it but doesn't display the tag info.  This problem also occurs on a
netware volume where the user has only read and file-scan rights and
when a file has the read-only attribute set..

2) The code doesn't decode the "genre" field.  I haven't yet
discovered how to decode that last field.  If anyone can tell me,
please do.

In the code sample below remember that at least one line has wrapped
to the next for display purposes.

I'm pretty sure that the reversal would work just as well, writing the
record to the file.  In this case, though you'd absolutely need to
adjust the record length to the proper length.

Hope this helps.

Jim

Type MP3Tag
    Title As String * 30
    Artist As String * 30
    Album As String * 30
    Comments As String * 30
    Year As String * 4
    Genre As String * 1
End Type

Sub GetTAGInfo(lpzsFile As String)
    Temp$ = lpzsFile
    Dim Rec As String * 140
    Dim Rec1 As String * 140
    mMP3Tag.Album = ""
    mMP3Tag.Artist = ""
    mMP3Tag.Comments = ""
    mMP3Tag.Title = ""
    mMP3Tag.Year = ""
    mMP3Tag.Genre = ""
    FileNumber = FreeFile
    On Error Resume Next
    Open Temp$ For Binary Access Read Shared As #FileNumber
    ErrorCoded = Err
    Get #FileNumber, FileLen(Temp$) - 140, Rec1
    If InStr(Rec1, "TAG") Then
        Get #FileNumber, FileLen(Temp$) - 124, Rec
        Get #FileNumber, FileLen(Temp$) - 124, mMP3Tag.Title
        Get #FileNumber, (FileLen(Temp$) - 124) + 30, mMP3Tag.Artist
        Get #FileNumber, (FileLen(Temp$) - 124) + 30 * 2,
mMP3Tag.Album
        Get #FileNumber, (FileLen(Temp$) - 124) + 30 * 3, mMP3Tag.Year
    Else
        If ErrorCoded <> 0 Then
            Title = "Rights Error on Remote Volume"
            Artist = ""
            Album = ""
        Else
            Title = "ID3 Tag Missing"
            Artist = ""
            Album = ""
        End If
    End If
    Close #FileNumber
End Sub



Tue, 16 Jan 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Read & write mp3 ID3v2 Tags

2. MP3 playing and editting tag info

3. MP3 Tag Info

4. How to read mp3 ID3v1 Tag and other properties in ACCESS VBA

5. Read MP3 Tag informations via VB.NET?

6. how can I read MP3-Tags

7. Reading MP3 ID3 Tag

8. Help Reading ID3 Tag Information from MP3 file

9. How To Write Id3 Tag Info

10. Read MP3 info

11. Reading .mp3 file info using VB

12. MP3 read/write

 

 
Powered by phpBB® Forum Software