Forum: VB.NET |
Thema:
Re: ID3 Tag auslesen |
Von:
Raphael Crivelli (
10.04.2005 14:12) |
Hallo
Ich hab den Code im Netz gefunden. Vielleicht hilft er dir weiter.
Dim sr As IO.BinaryReader
Dim Chars(255) As Char
Dim Titel, Interpret, EndString As String
Dim mehrBytes(255) As Byte
Dim BytesToRead As Integer = 256
Dim BytesRead As Integer = 0
Dim EndPath As String
Dim position As Integer
Dim strStart As Integer
Dim strEnd As Integer = 35
Dim strStop As Integer
sr = New IO.BinaryReader(New IO.FileStream(datei.FullName, IO.FileMode.Open, IO.FileAccess.Read))
While BytesToRead > 0
n = sr.Read(mehrBytes, BytesRead, BytesToRead)
BytesToRead = BytesToRead - n
BytesRead = BytesRead + n
End While
sr.Close()
' In Chars convertieren
For i = 0 To 255
Chars(i) = Convert.ToChar(mehrBytes(i))
Next
System.Windows.Forms.Application.DoEvents()
strStop = InStr(Chars, "MP3ext")
' Titel Finden
Titel = Chars
strStart = InStr(Chars, "TIT2") + 10 ' Zum anfang der Titel spulen... komischerweise sind das immer +10
' Dafür sorgen, das nicht in die Datei hineingelesen wird
If strStart + strEnd > 255 Then strEnd = 255 - strStart
If strStop <> 0 And strStart + strEnd > strStop Then strEnd = strStop - strStart
txtTitel.Text = Titel.Substring(strStart, strEnd)
' Falls letzen 4 Buchstaben schon nächster Tag; abschneiden.
For i = 0 To 74
If Microsoft.VisualBasic.Right(txtTitel.Text, 4) = Tags(i) Then txtTitel.Text = Microsoft.VisualBasic.Left(txtTitel.Text, Len(txtTitel.Text) - 4)
Next
' Interpreten Finden
Interpret = Chars
strStart = InStr(Chars, "TPE1") + 10 ' Zum anfang der Titel spulen... komischerweise sind das immer +10
' Dafür sorgen, das nicht in die Datei hineingelesen wird
If strStart + strEnd > 255 Then strEnd = 255 - strStart
If strStop <> 0 And strStart + strEnd > strStop Then strEnd = strStop - strStart
txtInterpret.Text = Interpret.Substring(strStart, strEnd)
' Falls letzen 4 Buchstaben schon nächster Tag; abschneiden.
For i = 0 To 74
If Microsoft.VisualBasic.Right(txtInterpret.Text, 4) = Tags(i) Then txtInterpret.Text = Microsoft.VisualBasic.Left(txtInterpret.Text, Len(txtInterpret.Text) - 4)
Next
EndPath = datei.DirectoryName & "\" & txtInterpret.Text & " - " & txtTitel.Text & ".mp3"
Gruss Raffi
Betreff |
Von |
Datum |
|
|
G.
Guest
|
10.04.2005 15:31 |
|
|
Raphael
Crivelli
|
11.04.2005 08:52 |
|
|
G.
Guest
|
29.04.2005 17:45 |
|
|
Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!