advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Partners & Affiliates
advertisement
advertisement
Tip of the Day
Average Rating: 5/5 | Rate this item | 3 users have rated this item.
Tip formerly from VB2TheMax
Expertise: Intermediate
Language: VB5,VB6
July 14, 2001
GetMP3Info - Get info in the standard ID3 tag of the specified MP3 file
Private Type MP3TagInfo
    tag 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 String * 1
End Type

' Retrieve the informations contained into the standard ID3 tag
' of the specified MP3 file
' Return an array of 6 elements with the following meaning:
'   - index 0: song title
'   - index 1: artist
'   - index 2: album
'   - index 3: year
'   - index 4: comment
'   - index 5: genre: this is an integer value --> use any MP3 player,
'  such as Winamp,
'       to look for the descriptions
'
' Example
'    Dim mp3info() As String
'    Dim sDescr As String
'    ' get the infos
'    mp3info = GetMP3Info("C:\MyMusic\Demo.mp3")
'    ' build and show a description string
'    sDescr = "Title: " & mp3info(0) & vbCrLf & '        "Artist: " & mp3info(1)
'  & vbCrLf & '        "Album: " & mp3info(2) & vbCrLf & '        "Year: " & 
' mp3info(3) & vbCrLf & '        "Comment: " & mp3info(4) & vbCrLf & '        
' "Genre: " & mp3info(5)
'    MsgBox sDescr

Function GetMP3Info(ByVal sFileName As String) As String()
    Dim mp3info As MP3TagInfo
    Dim infoRet(5) As String
    
    On Error Resume Next
    ' open the specified file
    Open sFileName For Binary As #1
    ' fill the strct's fileds
    With mp3info
        Get #1, FileLen(sFileName) - 127, .tag
        If Not .tag = "TAG" Then
            Close #1
            Exit Function
        End If
        Get #1, , .title
        Get #1, , .artist
        Get #1, , .album
        Get #1, , .year
        Get #1, , .comment
        Get #1, , .genre
        Close #1
    End With
    
    ' from struct to array
    infoRet(0) = Trim$(mp3info.title)
    infoRet(1) = Trim$(mp3info.artist)
    infoRet(2) = Trim$(mp3info.album)
    infoRet(3) = Trim$(mp3info.year)
    infoRet(4) = Trim$(mp3info.comment)
    infoRet(5) = CInt(Asc(Trim$(mp3info.genre))) - 1
    'return the array
    GetMP3Info = infoRet
End Function
Marco Bellinaso
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
Please rate this item (5=best)
 1  2  3  4  5
advertisement
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Help  |   Site Map  |   Network Map  |   About


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers