ID3v1标签存储在文件的最后128个字节中。前三个字节是“TAG”,告诉文件存储标签。所以首先检查文件是否有标签,然后阅读它们。
我不知道VB的,但我认为阅读框架之前,你应该先:
- 打开文件
Dim objMP3V1 As New MP3ID3v1("file_path")
- 测试,如果文件中有一个的ID3v1标签通过,如果
objMP3V1.TagExists
标志测试是真的
- 然后阅读字段/框架。
编辑
在链接的代码表示
FileGet(intFile, strTag, lngLOF - 127, True)
If (strTag.ToUpper <> "TAG") Then
' No ID3v1 tag found
mblnTagExists = False
mobjFrame(0) = ""
mobjFrame(1) = ""
mobjFrame(2) = ""
mobjFrame(3) = ""
mobjFrame(4) = ""
mobjFrame(5) = ""
mobjFrame(6) = ""
Else
' ID3v1 tag found
mblnTagExists = True
' Read all frames from the file
FileGet(intFile, strTitle)
FileGet(intFile, strArtist)
FileGet(intFile, strAlbum)
FileGet(intFile, strYear)
FileGet(intFile, strComment)
FileGet(intFile, bytDummy)
FileGet(intFile, bytTrack)
FileGet(intFile, bytGenre)
' Assign the frame content to the properties
mobjFrame(0) = strTitle
mobjFrame(1) = strArtist
mobjFrame(2) = strAlbum
mobjFrame(3) = strYear
mobjFrame(4) = bytTrack
mobjFrame(5) = strComment
mobjFrame(6) = bytGenre
End If
End If
因此,如果标签不存在,那么它应该有""
指定为字符串。
的ID3v1字段是固定长度的,所以如果有在album
字段没有字符串,那么它应该含有一个NUM串,即,该字段的第一位置将包含一个空字符'\0'
,因此它会返回一个空字符串""
。 我会告诉你在带有ID3v1标签的示例音乐文件上检查这一点。 (你甚至可以创建一个用ID3v1格式化的文本文件并测试它)。
+1,我也有同样的问题 – Predator 2011-06-12 08:10:00
链接的代码相当笨拙。使用如果album.Trim()=“”然后 – 2011-06-12 18:33:09