VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



MP3 ID3v1 Tag Read/Write Class

by Kevin Roth (2 Submissions)
Category: Sound/MP3
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

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

Inputs
Must pass full file paths to the gettag and writetag subs

Rate MP3 ID3v1 Tag Read/Write Class

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

Download this snippet    Add to My Saved Code

MP3 ID3v1 Tag Read/Write Class Comments

No comments have been posted about MP3 ID3v1 Tag Read/Write Class. Why not be the first to post a comment about MP3 ID3v1 Tag Read/Write Class.

Post your comment

Subject:
Message:
0/1000 characters