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