|
Option Explicit
Private Path As String
Private Sub cmdLoad_Click()
Dim T As TagInfo
cdLoad.ShowOpen
Path = cdLoad.FileName
If GET_ID3V1TAG(Path, T) Then
txtAlbum.Text = T.album
txtArtist.Text = T.artist
txtComment.Text = T.comment
txtGenere.Text = T.genre
txtTitle.Text = T.Songname
txtYear.Text = T.year
Else
txtAlbum.Text = ""
txtArtist.Text = ""
txtComment.Text = ""
txtGenere.Text = ""
txtTitle.Text = ""
txtYear.Text = ""
MsgBox "Kein ID3v1 Tag gefunden", vbInformation, "Info"
End If
End Sub
Private Sub cmdSave_Click()
Dim T As TagInfo
T.album = txtAlbum.Text
T.artist = txtArtist.Text
T.comment = txtComment.Text
T.genre = txtGenere.Text
T.Songname = txtTitle.Text
T.year = txtYear.Text
If Not PUT_ID3V1TAG(Path, T) Then MsgBox "Fehler: Konnte keinen ID3v2 Tag schreiben", _
vbCritical, "Fehler"
End Sub
Private Sub Form_Load()
cdLoad.Filter = "MP3-Dateien (*.mp3)|*.mp3"
End Sub
Option Explicit
Public Type TagInfo
TAG As String * 3
Songname As String * 30
artist As String * 30
album As String * 30
year As String * 4
comment As String * 30
genre As String * 1
End Type
Public Path$, WINAMPPATH$
Public Function GET_ID3V1TAG(FilePath$, TAG As TagInfo) As Boolean
Dim FNum%, fso As New FileSystemObject
On Error Goto ERRORS
If Not fso.FileExists(FilePath) Then
GET_ID3V1TAG = False
Exit Function
End If
With TAG
FNum = FreeFile
Open FilePath For Binary As #FNum
Get #FNum, LOF(FNum) - 127, .TAG
If .TAG <> "TAG" Then
GET_ID3V1TAG = False
Close #FNum
Exit Function
End If
Get #FNum, , .Songname
Get #FNum, , .artist
Get #FNum, , .album
Get #FNum, , .year
Get #FNum, , .comment
Get #FNum, , .genre
Close #FNum
GET_ID3V1TAG = True
End With
Exit Function
ERRORS:
GET_ID3V1TAG = False
Close #FNum
End Function
Public Function PUT_ID3V1TAG(FilePath$, TAG As TagInfo) As Boolean
Dim FNum%, TPos&
On Error Goto ERRORS
With TAG
FNum = FreeFile
Open FilePath For Binary As #FNum
TPos = LOF(FNum)
Get #FNum, TPos - 127, .TAG
If .TAG = "TAG" Then TPos = TPos - 127
.TAG = "TAG"
Put #FNum, TPos, TAG
Close #FNum
PUT_ID3V1TAG = True
End With
Exit Function
ERRORS:
PUT_ID3V1TAG = False
End Function
|