Advertisement
3_2004-2005 Sound/MP3 #141280

MP3 ID3v1 Tag Read/Write Class

Use this class to read and/or write to the ID3 tag of an MP3.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Public ValidTag As String
Public Title As String
Public Artist As String
Public Year As String
Public Album As String
Public Comment As String
Public Genre As Byte
Private Type ID3v1
  ValidTag As String * 3
  Title As String * 30
  Artist As String * 30
  Album As String * 30
  Year As String * 4
  Comment As String * 30
  Genre As Byte
End Type
  
Public Sub getTag(MP3 As String)
  Dim ID3 As ID3v1
  Open MP3 For Binary As #1
  Get #1, FileLen(MP3) - 127, ID3
  Close #1
  
  With ID3
   ValidTag = .ValidTag
   Title = .Title
   Artist = .Artist
   Album = .Album
   Comment = .Comment
   Year = .Year
   Genre = .Genre
  End With
End Sub
Public Sub writeTag(MP3 As String)
  Dim ID3 As ID3v1
  
  With ID3
   .ValidTag = "TAG"
   .Title = Title
   .Artist = Artist
   .Album = Album
   .Comment = Comment
   .Year = Year
   .Genre = Genre
  End With
  On Error GoTo ErrMsg:
  Open MP3 For Binary As 1
  If ID3.ValidTag <> "TAG" Then
    Seek 1, LOF(1) + 1
  Else
    Seek 1, LOF(1) - 127
  End If
  Put 1, FileLen(MP3) - 127, ID3
  Close 1
  Exit Sub
ErrMsg:
  MsgBox ("File '" & MP3 & "' is marked as read-only or the file is in use." & vbCr & "Please correct and try again.")
End Sub
Original Comments (3)
Recovered from Wayback Machine