-2
나는 속성에있는 MP3의 제목을 얻으려고합니다. 예를 들어 파일 이름은 "iasn_E_052"이지만 노래 제목은 "Guard Your Heart"입니다. 파일 이름을 얻는 것은 쉽지만 노래 제목은 어떻게해야할지 모르겠다. 나는 vb.net visual studio 2013을 사용하고 있습니다.VB.net의 MP3 제목
나는 속성에있는 MP3의 제목을 얻으려고합니다. 예를 들어 파일 이름은 "iasn_E_052"이지만 노래 제목은 "Guard Your Heart"입니다. 파일 이름을 얻는 것은 쉽지만 노래 제목은 어떻게해야할지 모르겠다. 나는 vb.net visual studio 2013을 사용하고 있습니다.VB.net의 MP3 제목
제목이나 아티스트 같은 메타 데이터는 파일에 ID3으로 저장됩니다. 파일을 바이트 단위로 읽고 특정 바이트를 문자열로 변환해야합니다.
예를 들어 ID3v1 태그는 파일의 마지막 128 바이트에 저장됩니다. 처음 세 바이트는 "태그"이고 다음 30 바이트는 제목입니다.
Option Strict On
Imports System.IO
Class MP3Tags
Sub GetTitle(filename As String)
Dim buffer(30) As Byte
Dim reader As New FileStream(filename, FileMode.Open, FileAccess.Read)
Dim length = reader.Length
If (length > 128) Then
reader.Seek(-128, SeekOrigin.End)
reader.Read(buffer, 0, 3)
Dim tag As String = System.Text.Encoding.ASCII.GetChars(buffer, 0, 3)
If (tag = "TAG") Then
reader.Read(buffer, 0, 30)
Dim title As String = System.Text.Encoding.ASCII.GetChars(buffer, 0, 30)
Console.WriteLine("Title = " + title)
Else
Console.WriteLine("File doesn't contain ID3v1 tags")
End If
Else
Console.WriteLine("File is too short to have tags")
End If
End Sub
End Class
는
( class이 기준)