|
-
Jul 29th, 2002, 12:32 PM
#1
Thread Starter
Member
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 ?
-
Jul 29th, 2002, 12:36 PM
#2
verify that songname is even populated in the mp3 tag. open it in winamp or something and see if songname shows up.
-
Jul 29th, 2002, 12:43 PM
#3
Thread Starter
Member
It is populated !!!!!
My test file have perfect id3 tags, of course.
-
Jul 29th, 2002, 12:52 PM
#4
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
-
Jul 29th, 2002, 01:11 PM
#5
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|