-
MP3 Organizer
I'm trying to do an MP3 organizer, so that I can have all my MP3s organized ("ordered by") Artist, Theme, Album, or whatever. I've already "found" how to get all the info from an MP3, but the problem is that it's too slow (extremely slow). The Open statement to read the file is quite slow. Do you know any other way to do this. Here's the code:
Code:
Private Type MP3FrameData
Tag As String
Title As String
Artist As String
Album As String
Year As Integer
Comment As String
Genre As Integer
End Type
Private Sub Form_Load()
Dim MP3Frames As String
Dim MP3Info() As MP3FrameData
ReDim MP3Info(0) As MP3FrameData
MP3s.Path = "C:\Downloaded Files\MP3"
For i = 0 To MP3s.ListCount - 1
DoEvents
ReDim Preserve MP3Info(UBound(MP3Info) + 1) As MP3FrameData
Open MP3s.Path & "\" & MP3s.List(i) For Binary As #1
MP3Frames = Input(LOF(1), 1)
Close #1
MP3Frames = Mid$(MP3Frames, Len(MP3Frames) - 127)
With MP3Info(UBound(MP3Info))
.Tag = GetInfo(MP3Frames, 3)
.Title = GetInfo(MP3Frames, 30)
.Artist = GetInfo(MP3Frames, 30)
.Album = GetInfo(MP3Frames, 30)
.Year = Val(GetInfo(MP3Frames, 4))
.Comment = GetInfo(MP3Frames, 30)
.Genre = Val(GetInfo(MP3Frames, 1))
End With
Next i
End
End Sub
Private Function GetInfo(FullData As String, Lenght As Integer)
GetInfo = Trim$(Trim0(Left$(FullData, Lenght)))
FullData = Mid$(FullData, Lenght + 1)
End Function
Private Function Trim0(Data As String)
Dim i As Integer
For i = Len(Data) To 1 Step -1
If Mid$(Data, i, 1) <> Chr$(0) Then Exit For
Next i
Trim0 = Left$(Data, i)
End Function
-
You can use API to open your files:
Public Const OFS_MAXPATHNAME = 128
Public Type OFSTRUCT
cBytes As Byte
fFixedDisk As Byte
nErrCode As Integer
Reserved1 As Integer
Reserved2 As Integer
szPathName(OFS_MAXPATHNAME) As Byte
End Type
Public Declare Function OpenFile Lib "kernel32" Alias "OpenFile" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
May the luck guide you,
-
Could you give me a little more luck? I can't understand how to get all the file's contents.