Results 1 to 5 of 5

Thread: ID3 Tag

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2002
    Posts
    32

    ID3 Tag

    I tried this to extract id3tags:


    Dim strFile As String
    Dim strTag As String
    Dim strSongname As String
    Dim strArtist As String
    Dim strAlbum As String
    Dim strYear As String
    Dim strComment As String
    Dim strGenre As String

    For Each strFile In Filelist
    strTag = New String(" "c, 3)
    strSongname = New String(" "c, 30)
    strArtist = New String(" "c, 30)
    strAlbum = New String(" "c, 30)
    strYear = New String(" "c, 4)
    strComment = New String(" "c, 30)
    strGenre = New String(" "c, 1)
    Try
    ' open the file for read into a filestream
    FileOpen(1, strFile, OpenMode.Binary)
    ' read the tag info
    FileGet(1, strTag, FileLen(strFile) - 127)
    objTag = New clsID3Tag()
    ' if .tag is equal to "TAG" then the song has a ID3 tag an we read on
    If strTag = "TAG" Then
    FileGet(1, strSongname)
    FileGet(1, strArtist)
    FileGet(1, strAlbum)
    FileGet(1, strYear)
    FileGet(1, strComment)
    FileGet(1, strGenre)
    Else
    strSongname = "NoTag"
    End If
    Catch
    strSongname = "NoTag"
    End Try
    MsgBox(strArtist & " - " & strSongname)
    FileClose(1)

    Next


    The problem is that "MsgBox(strArtist & " - " strSongname) " at the end of the code only returns the contents of the of "strArtist".
    The string concatenation with "&" does'nt seem to work.

    Who can help me ?

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    verify that songname is even populated in the mp3 tag. open it in winamp or something and see if songname shows up.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2002
    Posts
    32
    It is populated !!!!!
    My test file have perfect id3 tags, of course.

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    try this

    Code:
    
                Private Structure typMP3ID3 
                    Public sTag As String  
                    Public sTitle As String  
                    Public sArtist As String  
                    Public sAlbum As String  
                    Public sYear As String 
                    Public sComment As String  
                    Public sGenre As String  
                End Structure 
    
                Dim m_udtMP3ID3 As typMP3ID3 
    
                Private Sub Form_Load() 
    
                    Dim strFilePath As String 
                    strFilePath = "d:\test.mp3" 
                    With m_udtMP3ID3 
                        .sTag = Space(3) 
                        .sTitle = Space(30) 
                        .sArtist = Space(30) 
                        .sAlbum = Space(30) 
                        .sYear = Space(4) 
                        .sComment = Space(30) 
                        .sGenre = Space(1) 
                    End With 
                    FileOpen(1, strFilePath, OpenMode.Binary) 
                    FileGet(1, m_udtMP3ID3) 
                    FileClose(1) 
    
                    With m_udtMP3ID3 
                        If .sTag = "TAG" Then 
                            MsgBox(.sAlbum & vbCrLf _ 
                               & .sArtist & vbCrLf _ 
                               & .sComment & vbCrLf _ 
                               & .sGenre & vbCrLf _ 
                               & .sTag & vbCrLf _ 
                               & .sTitle & vbCrLf _ 
                               & .sYear & vbCrLf) 
                        Else 
                            MsgBox(LCase(strFilePath) & vbCrLf _ 
                               & "NO ID3 TAG FOUND!") 
                        End If 
                    End With 
    
                    Me.Close() 
                End Sub
    adapt as needed
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2002
    Posts
    32
    Originally posted by Cander
    try this

    Code:
    
                Private Structure typMP3ID3 
                    Public sTag As String  
                    Public sTitle As String  
                    Public sArtist As String  
                    Public sAlbum As String  
                    Public sYear As String 
                    Public sComment As String  
                    Public sGenre As String  
                End Structure 
    
                Dim m_udtMP3ID3 As typMP3ID3 
    
                Private Sub Form_Load() 
    
                    Dim strFilePath As String 
                    strFilePath = "d:\test.mp3" 
                    With m_udtMP3ID3 
                        .sTag = Space(3) 
                        .sTitle = Space(30) 
                        .sArtist = Space(30) 
                        .sAlbum = Space(30) 
                        .sYear = Space(4) 
                        .sComment = Space(30) 
                        .sGenre = Space(1) 
                    End With 
                    FileOpen(1, strFilePath, OpenMode.Binary) 
                    FileGet(1, m_udtMP3ID3)  <- this does not work under VB.Net 
                    FileClose(1) 
    
                    With m_udtMP3ID3 
                        If .sTag = "TAG" Then 
                            MsgBox(.sAlbum & vbCrLf _ 
                               & .sArtist & vbCrLf _ 
                               & .sComment & vbCrLf _ 
                               & .sGenre & vbCrLf _ 
                               & .sTag & vbCrLf _ 
                               & .sTitle & vbCrLf _ 
                               & .sYear & vbCrLf) 
                        Else 
                            MsgBox(LCase(strFilePath) & vbCrLf _ 
                               & "NO ID3 TAG FOUND!") 
                        End If 
                    End With 
    
                    Me.Close() 
                End Sub
    adapt as needed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width