Hallo zusammen,
ich habe ein kleines Problem mit einer Software die ich aktuell erstelle..
Ich habe zwar in der Suche geschaut, aber nichts gefunden, also bitte den Kopf nicht abreißen
Ich baue aktuell einen kleinen PC für mein Auto und entwickle dafür gerade die Software.
Nun hänge ich grade bei der Multimedia-Sektion ...
Das Programm soll alle MP3 Dateien aus einem vorgegebenen Ordner auslesen und in die Mediathek (vorerst eine kleine Tabelle) einreihen.
Den Code hierzu habe ich zwar, nur dauert es Ewigkeiten ...
Selbst das erkennen von 1 Album á 60 Tracks dauert eine gute halbe Minute, das ist mir zu viel.
Wie gesagt, es funktioniert, ist mir aber viel zu langsam.
Kann mir jemand helfen dieses Problem zu beseitigen?
Danke schonmal,
Gruß, DJDeagle
ich habe ein kleines Problem mit einer Software die ich aktuell erstelle..
Ich habe zwar in der Suche geschaut, aber nichts gefunden, also bitte den Kopf nicht abreißen
Ich baue aktuell einen kleinen PC für mein Auto und entwickle dafür gerade die Software.
Nun hänge ich grade bei der Multimedia-Sektion ...
Das Programm soll alle MP3 Dateien aus einem vorgegebenen Ordner auslesen und in die Mediathek (vorerst eine kleine Tabelle) einreihen.
Den Code hierzu habe ich zwar, nur dauert es Ewigkeiten ...
Selbst das erkennen von 1 Album á 60 Tracks dauert eine gute halbe Minute, das ist mir zu viel.
VB.NET-Quellcode
- 'Form1
- '[...]
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Form2.Show()
- Form2.GetMusic()
- End Sub
- '[...]
- 'Form2
- Imports System.IO
- Imports System.Text
- Imports System.String
- Public Class Form2
- Dim File, Files() As FileInfo
- Dim Mp3File As Object = CreateObject("Scripting.FileSystemObject")
- Dim searchtype As String = "*.mp3"
- Dim nr As Integer = 0
- Dim c As Integer = 0
- Dim sBuffer As String
- Dim Str As String
- Dim MyString(127) As String
- Dim alltitles(0 To 50000) As String
- Dim allartists(0 To 50000) As String
- Dim allalbums(0 To 50000) As String
- Dim allalbumyears(0 To 50000) As String
- Dim title, artist, album, albumyear, comment, genre As String
- Private Property Folders As ObjectModel.ReadOnlyCollection(Of String)
- Dim FSO As Object
- Dim nrs As String = ""
- Public Sub GetMusic()
- BackgroundWorker1.RunWorkerAsync()
- End Sub
- Public Sub GetFiles(ByVal dir As String, ByVal type As String)
- Dim found As FileInfo
- Dim Path As New DirectoryInfo(dir)
- ' Die Namen aller Dateien anzeigen.
- Try
- Files = Path.GetFiles(type)
- Catch ex As Exception
- Form1.RichTextBox1.Text &= "Exception aufgetreten: " & ex.Message & vbNewLine
- End Try
- For Each File In Files
- FSO = CreateObject("Scripting.FileSyste" & "mObject")
- Mp3File = FSO.OpenTextFile(File.FullName, 1, False, 0)
- sBuffer = Mp3File.ReadAll
- For i = 0 To 124
- MyString(i) = Asc(Microsoft.VisualBasic.Right(sBuffer, i + 1))
- Next
- Dim charx As String = ""
- title = Nothing
- artist = Nothing
- album = Nothing
- albumyear = Nothing
- comment = Nothing
- genre = Nothing
- For x = 0 To 124
- c = 124 - x
- If MyString(c) = 0 Then
- charx = Nothing
- Else
- charx = Chr(MyString(c))
- End If
- 'nrs &= c & " - " & charx & vbNewLine
- If c > 94 And c <= 127 Then title &= charx
- If c > 64 And c <= 94 Then artist &= charx
- If c > 34 And c <= 64 Then album &= charx
- If c > 30 And c <= 34 Then albumyear &= charx
- If c > 0 And c <= 30 Then comment &= charx
- If c = 0 Then genre = charx
- Next
- alltitles(nr) = title
- allartists(nr) = artist
- allalbums(nr) = album
- allalbumyears(nr) = albumyear
- nr += 1
- FSO = Nothing
- Next
- End Sub
- Public Sub GetSubfolders(ByVal homedir As String)
- GetFiles(homedir, searchtype)
- Folders = My.Computer.FileSystem.GetDirectories(homedir)
- For Each folder As String In Folders
- If Not Folders.Equals(Nothing) Then
- GetSubfolders(folder)
- End If
- GetFiles(folder, searchtype)
- Next
- End Sub
- Private Sub bgwDoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
- Dim startdir As String = "I:\Muke\Alben\Best of Hardstyle 2011!"
- GetSubfolders(startdir)
- End Sub
- Private Sub bgwCompleted() Handles BackgroundWorker1.RunWorkerCompleted
- MsgBox("Fertig, " & nr & " Einträge gefunden!")
- For i As Integer = 0 To nr - 1
- DataGridView1.Rows.Add(i, alltitles(i), allartists(i), allalbumyears(i))
- Next
- End Sub
- End Class
Wie gesagt, es funktioniert, ist mir aber viel zu langsam.
Kann mir jemand helfen dieses Problem zu beseitigen?
Danke schonmal,
Gruß, DJDeagle