在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
但没有成功,有人可以帮助我。     
已邀请:
        ID3v1标记存储在文件的最后128个字节中。前三个字节是\“ TAG \”,表示文件存储了标签。因此,首先检查文件中是否有标签,然后再读取它们。 我不了解VB,但我认为在阅读框架之前,您应该先: 打开文件
Dim objMP3V1 As New MP3ID3v1(\"file_path\")
通过测试
objMP3V1.TagExists
标志是否为真来测试文件中是否具有ID3v1标记 然后阅读字段/框架。 编辑 链接中的代码说
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
因此,如果标签不存在,则应将“ 5”分配为字符串。 ID3v1字段的长度是固定的,因此如果
album
字段中没有字符串,则它应包含一个num字符串,即该字段的第一个位置将包含一个空字符
\'\\0\'
,因此它将返回一个空字符串
\"\"
。 我会告诉您在带有ID3v1标签的示例音乐文件中检查此内容。 (您甚至可以创建一个使用ID3v1格式化的文本文件并进行测试)。     
        我使用正则表达式来解决此问题。感谢你的帮助...
Imports System.Text.RegularExpressions
dim RegEx As New RegularExpressions.Regex(\"^[a-zA-Z0-9]+$\")
dim Match As Match
dim film as string
film = song.Frame(MP3ID3v1.FrameTypes.Album)
Match = RegEx.Match(film)
film1 = IIf((Match.Success), film.ToString, \"\")  
如果您正在寻找更专业的标签编辑器,请点击这里。     

要回复问题请先登录注册