Sub testcddb()
Dim cddbft As CDDBCONTROLLib.CddbFileTag, sFileName As String
Set cddbft = CreateObject("CDDBControl.CddbID3Tag")
sFileName = "C:\Ushare\Music est.mp3"
cddbft.LoadFromFile sFileName, UI_EDITMODE
'cddbft.Title = "New Title"
'cddbft.SaveToFile sFileName
MsgBox cddbft.Title
End Sub
'The Windows Media Player provides an easy, quick way to drop MP3
'capability into a Visual Basic application. However, once you have
'an MP3, you may have wondered how to read information about the song,
'such as the song title and artist's name. If the MP3 file uses the
'most popular tag encryption, ID3, then you're in luck. This standard
'stores the Tag information in the last 128 bytes of the file
'(Tag:3, Title:30, Artist:30, Album:30, Year:4, Comment:30, Genre:1)
'
'To read this information, first open the MP3 file and grab the last
'128 bytes. With ID3, the first three slots hold the string TAG if the
'file actually contains information. If the file does contain Tag
'information, store the last 128 bytes in a custom variable. After that,
'cycle through the MP3 file, extracting information as you go. The
'following procedure shows the code that extracts this information as
'well as creates several important variables to use later on:
Sub test()
Dim a As String, b As String, C As String, d As String, e As String, f As String, g As String, h As String
GetTagInfo "C:\uShare\Music\Burn1\01a All I've Got To Do.mp3", a, b, C, d, e, f, g, h
Debug.Print "Tag", a
Debug.Print "Title", b
Debug.Print "Artist", C
Debug.Print "Album", d
Debug.Print "Year", e
Debug.Print "Comment", f
Debug.Print "Track", g
Debug.Print "Genre", h
End Sub
Public Sub GetTagInfo(Filename As String, _
Tag As String, _
Title As String, _
Artist As String, _
Album As String, _
Year As String, _
Comment As String, _
Track As String, _
Genre As String)
Dim CurrentTag As TagInfo
Open Filename For Binary As #1
With CurrentTag
Get #1, FileLen(Filename) - 127, .Tag
Tag = .Tag
If Tag = "TAG" Then
Get #1, , .Title
Get #1, , .Artist
Get #1, , .Album
Get #1, , .Year
Get #1, , .Comment
Get #1, , .GenreCode
Else
Tag = "No tag"
.Title = ""
.Artist = ""
.Comment = ""
.GenreCode = Chr(255)
.Title = ""
.Year = ""
End If
Close #1
Title = RTrim(.Title)
Artist = RTrim(.Artist)
Album = RTrim(.Album)
Year = RTrim(.Year)
Comment = .Comment
If Mid(Comment, 29, 1) = Chr(0) Then
Track = Trim(Str(Asc(Mid(Comment, 30, 1))))
Comment = RTrim(Left(Comment, 28))
Else
Track = ""
Comment = RTrim(Comment)
End If
Genre = fGetGenre(Asc(.GenreCode))
End With
End Sub