vb.net中读取mp3标签信息
我正在VB.NET 2005中做一个项目,其中我必须提取mp3文件的标签信息。为此,我在此页面中使用了代码。但问题是当其中一个标签为空时,它不会返回任何值。
例如,使用这个我可以像这样检索专辑信息,
Dim album As String = ""
album = objMP3V1.Frame(MP3ID3v1.FrameTypes.Album)
但我不知道如何检查专辑变量是否为空,我检查了专辑变量
If (album = "") Then
MsgBox("true")
ElseIf (album Is Nothing) Then
MsgBox("true")
ElseIf (album Is DBNull.Value) Then
MsgBox("true")
End If
但没有成功,有人可以帮助我。
I'm doing a project in VB.NET 2005, in which I have to extract the tag information of mp3 files. For that purpose I have used code in this page. But the issue is when one of the tag is empty, it didn't return any values.
For example, using this i can retrieve album information like this,
Dim album As String = ""
album = objMP3V1.Frame(MP3ID3v1.FrameTypes.Album)
But I didn't know how to check the album variable is empty or not, I checked album variable
If (album = "") Then
MsgBox("true")
ElseIf (album Is Nothing) Then
MsgBox("true")
ElseIf (album Is DBNull.Value) Then
MsgBox("true")
End If
but no success, can somebody help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ID3v1 标签存储在文件的最后 128 个字节中。前三个字节是“TAG”,表示文件存储标签。所以首先检查文件是否有标签,然后读取它们。
我不懂VB,但我认为在阅读框架之前,您应该首先:
Dim objMP3V1 As New MP3ID3v1("file_path")
编辑
链接中的代码显示,
因此,如果标签不存在,则应将
""
指定为字符串。ID3v1字段是固定长度的,因此如果
album
字段中没有字符串,那么它应该包含一个num字符串,即该字段的第一个位置将包含一个空字符' \0'
,因此它将返回一个空字符串""
。我会告诉您在带有 ID3v1 标签的示例音乐文件上检查这一点。 (您甚至可以创建一个 ID3v1 格式的文本文件并进行测试)。
The ID3v1 tag is stored in the last 128 bytes of the file. The first three bytes is "TAG" telling that the file stores the tag. So first check if the file has a tag, Then read them.
I do not know VB but i think before reading the frame, you should first:
Dim objMP3V1 As New MP3ID3v1("file_path")
objMP3V1.TagExists
flag is trueEDIT
The code in the link says
So, if the tag is not present then it should have
""
assigned as the string.ID3v1 fields are of fixed length, so if there is no string in the
album
field then it should contain a num string, that is, the first location of the field will contain a null character'\0'
, therefore it will return a null string""
.I would tell you to check the this on a sample music file with ID3v1 tags. (You can even create a text file formatted with ID3v1 and test it).
我使用正则表达式来解决这个问题。感谢您的帮助...
如果您正在寻找更专业的标签编辑器,这里有链接!
I've used regular expression to solve this issue. Thanks for all your help...
If you looking for more professional tag editior Here's a link!