其实你可以去下个FREE的,分析一下代码不就可以了么??
不是么??我折断了手臂,只为了曾去拥抱白云
不是么??我折断了手臂,只为了曾去拥抱白云
解决方案 »
- 深挖VB高手-->USB摄像头监控
- vb,动态连接库,回调函数传字符串问题。急!!(100分求解)
- 关于图片处理的问题,且用鼠标控制图片旋转。。。。
- 怎样实现两个程序间的通信,进行数据传递?
- 急!!!:注册不了dll文件
- 我是新手,请教高手帮忙,急~~~~~~~~~
- 用VB写的OCX在IE中调用的问题,在主IE中调用OCX没问题,如果在弹出IE调用,关闭弹出IE时就会报异常?(急)
- 初学数据库:哪里有可供连接的免费SQL Server例子,测试一下
- 一个关于MDI窗体的问题?
- 在VB中如何用printer对象打印人民币符号?
- mschart表问题!
- 请问怎样使用mschart控件实现曲线图例!小弟急!
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "cMP3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option ExplicitPublic Enum ETagType
NoTag = 0
ID3v1Tag
ID3v2Tag
ID3v1andID3v2Tags
Lyrics3Tag
ID3v1andLyrics3Tags
ID3v2andLyrics3Tags
AllTags = 7
End EnumPublic Enum EDirStructure
No_Structure = 0
Artist_Album_Title = 1
Artist_Title = 2
Artist_Dash_Title = 3
Title_Dash_Artist = 4
End EnumPrivate Type udtID3v1Tag
id As String * 3
Title As String * 30
Artist As String * 30
Album As String * 30
Year As String * 4
Comment As String * 30
Genre As Byte
End Type'local variable(s) to hold property values
Private m_sFileName As String
Private m_sTitle As String
Private m_sArtist As String
Private m_sAlbum As String
Private m_sComment As String
Private m_sYear As String
Private m_Duration As Long
Private m_BitRate As Long
Private m_Frequency As Single
Private m_Genre As Long
Private m_FileSize As Long
Private m_IsVBR As Boolean
Private m_sLyrics As String
Private m_sQuality As String
Private m_sSituation As String
Private m_sMood As String
Private m_sAuthor As String
Private m_sOtherInfo As String
Private m_sImages As String
Private m_sUnknownFields As String
Private m_LastUpdate As Double
Private m_fValidFile As Boolean
Private m_TagType As ETagType
Private m_DirStructure As EDirStructure
Private m_fReadTagOnly As Boolean'private variables used in more than one procedure
Private UnknownLyrics3Fields As String
Private HasLyrics3Tag As Boolean
Private LSZ As String
Private Version As Byte
Public Event WriteComplete()
Public Event ReadComplete()Public Property Let ReadTagOnly(Tag As Boolean)
m_fReadTagOnly = Tag
End Property
Public Property Get ValidFile() As Boolean
ValidFile = m_fValidFile
End PropertyPublic Property Get LastUpdate() As Double
LastUpdate = m_LastUpdate
End PropertyPublic Property Let LastUpdate(NewLastUpdate As Double)
m_LastUpdate = NewLastUpdate
End PropertyPublic Property Get Lyrics() As String
Lyrics = m_sLyrics
End PropertyPublic Property Let Lyrics(NewLyrics As String)
m_sLyrics = NewLyrics
End PropertyPublic Property Get Quality() As String
Quality = m_sQuality
End PropertyPublic Property Let Quality(NewQuality As String)
m_sQuality = NewQuality
End PropertyPublic Property Get Situation() As String
Situation = m_sSituation
End PropertyPublic Property Let Situation(NewSituation As String)
m_sSituation = NewSituation
End PropertyPublic Property Get Mood() As String
Mood = m_sMood
End PropertyPublic Property Let Mood(NewMood As String)
m_sMood = NewMood
End PropertyPublic Property Get Author() As String
Author = m_sAuthor
End PropertyPublic Property Let Author(NewAuthor As String)
m_sAuthor = NewAuthor
End PropertyPublic Property Get OtherInfo() As String
OtherInfo = m_sOtherInfo
End PropertyPublic Property Let OtherInfo(NewOtherInfo As String)
m_sOtherInfo = NewOtherInfo
End PropertyPublic Property Get Images() As String
Images = m_sImages
End PropertyPublic Property Let Images(NewImages As String)
m_sImages = NewImages
End PropertyPublic Property Get TagType() As ETagType
TagType = m_TagType
End PropertyPublic Property Let Year(ByVal NewYear As String)
m_sYear = NewYear
End PropertyPublic Property Get Year() As String
Year = m_sYear
End PropertyPublic Property Get Frequency() As Single
Frequency = m_Frequency
End PropertyPublic Property Get BitRate() As Long
BitRate = m_BitRate
End Property
Public Property Get DurationInSecs()
DurationInSecs = m_Duration
End PropertyPublic Property Get Time() As String
Time = FormatTime(m_Duration)
End PropertyPublic Property Let GenreName(ByVal NewGenreName As String)
i = InStr(gsGenres, NewGenreName & Space$(22 - Len(NewGenreName)))
If i > 0 Then
m_Genre = Int(i / 22)
Else
m_Genre = 12
End If
End PropertyPublic Property Get GenreName() As String
GenreName = Trim$(Mid$(gsGenres, m_Genre * 22, 22))
End PropertyPublic Property Let Genre(ByVal NewGenreNumber As Long)
If NewGenreNumber < 0 Or NewGenreNumber > 147 Then NewGenreNumber = 12
m_Genre = NewGenreNumber
End PropertyPublic Property Get Genre() As Long
Genre = m_Genre
End PropertyPublic Property Let Comment(ByVal NewComment As String)
m_sComment = NewComment
End PropertyPublic Property Get Comment() As String
Comment = m_sComment
End PropertyPublic Property Let Album(ByVal NewAlbum As String)
m_sAlbum = NewAlbum
End PropertyPublic Property Get Album() As String
Album = m_sAlbum
End PropertyPublic Property Let Artist(ByVal NewArtist As String)
m_sArtist = NewArtist
End PropertyPublic Property Get Artist() As String
Artist = m_sArtist
End PropertyPublic Property Let Title(ByVal NewTitle As String)
m_sTitle = NewTitle
End PropertyPublic Property Get Title() As String
Title = m_sTitle
End PropertyPublic Property Let FileName(ByVal FileToRead As String)
m_sFileName = FileToRead
Reset
ReadFile
End PropertyPublic Property Get FileName() As String
FileName = m_sFileName
End PropertyPublic Property Get FileSize() As Long
FileSize = m_FileSize
End PropertyPublic Property Get IsVBR() As Boolean
IsVBR = m_IsVBR
End Property
Private Sub ReadFile()
Dim fn As Integer
Dim Y As Byte
Dim HeaderPosition As Long
Dim Tag1 As udtID3v1Tag
Dim Tag2 As String
Dim LyricEndID As String * 6
Dim sFileExt As String
UnknownLyrics3Fields = sEmpty
On Error GoTo Hell
fn = FreeFile
'sanity check
If m_sFileName = sEmpty Then Exit Sub
Open m_sFileName For Binary As #fn
m_FileSize = LOF(fn)
sFileExt = UCase$(Right$(m_sFileName, 3))
Select Case sFileExt
Case "MP3"
'get the header
Get #fn, 1, B
If B <> 255 Then '255 is start of header
If B <> 73 Then Exit Sub 'start of id3v2 tag
End If
HeaderPosition = 1
Get #fn, 2, B
If (B < 250 Or B > 251) Then 'next part of header
If B = 68 Then 'next part of id3v2 tag... one more to be sure
Get #fn, 3, B
If B = 51 Then 'last identifier. It is indeed a id3v2 tag, now how big is it?
Dim R As Double
Get #fn, 4, Version
Get #fn, 7, B
R = B * 20917152
Get #fn, 8, B
R = R + (B * 16384)
Get #fn, 9, B
R = R + (B * 128)
Get #fn, 10, B
R = R + B
If R > m_FileSize Or R > 2147483647 Then Exit Sub
Tag2 = Space$(R)
Get #fn, 11, Tag2
HeaderPosition = R + 11 'this is where the header should be if there are no
End If
Else
Exit Sub
End If
End If
If m_fReadTagOnly Then GoTo ReadTags
'read the rest of the header to get bitrate, etc.
Get #fn, HeaderPosition + 2, B
Y = B And 240
Y = Y \ 16
m_BitRate = Val(Mid$("144 16 32 48 56 64 80 96 112 128 160 192 224 256 320 ", Y * 4 + 1, 4))
Y = B And 12
Y = Y \ 2
m_Frequency = Val(Mid$("44.1 48 32 00.0 ", Y * 5 + 1, 5))
' check to see if it is a xing vbr file
s = Space$(4)
Get #fn, HeaderPosition + 36, s
If s = "Xing" Then
Dim nFrames As Long
Dim FrameLength As Long
m_IsVBR = True 'We have a xing header...
'get the number of frames from the next 4 bytes.
Get #fn, HeaderPosition + 44, B
L = B
Get #fn, HeaderPosition + 45, B
'this is a direct translation from c++, it is unusual to see something
'like it in a vb routine.
L = ((B And 255) Or (L * 256))
Get #fn, HeaderPosition + 46, B
L = ((B And 255) Or (L * 256))
Get #fn, HeaderPosition + 47, B
L = ((B And 255) Or (L * 256))
nFrames = L
FrameLength = m_FileSize / nFrames
m_BitRate = (FrameLength * (m_Frequency * 1000)) / 144000
End If
m_Duration = m_FileSize / (m_BitRate * 125) - 1
Case "WMA"
If m_fReadTagOnly Then GoTo ReadTags
For i = 1 To 1024
Get #fn, i, B
If B = 0 Then
Get #fn, , B
If B = 0 Then
Get #fn, , B
If B = 0 Then
Get #fn, , B
If B = 25 Then
Get #fn, , B
If B = 0 Then
'we should have the kbps here.
Get #fn, , s
m_BitRate = Val(StrConv(s, vbFromUnicode))
m_Duration = m_FileSize / (m_BitRate * 126)
Exit For
End If
End If
End If
End If
End If
Next i
Case "MID"
If m_fReadTagOnly Then Exit Sub
CheckMid
Case Else
Exit Sub
End Select
'fixes the stupid -01 second error.
If m_Duration < 0 Then m_Duration = 0
' now get the tags
ReadTags:
'id3v1 tag.
Get #fn, m_FileSize - 127, Tag1.id
Get #fn, , Tag1.Title
Get #fn, , Tag1.Artist
Get #fn, , Tag1.Album
Get #fn, , Tag1.Year
Get #fn, , Tag1.Comment
Get #fn, , Tag1.Genre
'lyrics3 tag
Get #fn, m_FileSize - 136, LyricEndID 'look for a lyrics 3 tag
Close
'ok now check for valid tags
'in the correct priority as processing the tags will fill the variables
'ID3v1 tag?
If Tag1.id = "TAG" Then
m_TagType = m_TagType Or ID3v1Tag
m_sTitle = Trim$(Tag1.Title)
m_sArtist = Trim$(Tag1.Artist)
m_sAlbum = Trim$(Tag1.Album)
m_sYear = Trim$(Tag1.Year)
m_sComment = Trim$(Tag1.Comment)
Genre = Tag1.Genre
End If
'id3v2 tag?
If Tag2 <> sEmpty Then f = GetID3v2Tag(Tag2)
If f Then m_TagType = m_TagType Or ID3v2Tag
'lyrics3 tag?
If LyricEndID = "LYRICS" Then 'got one, go get it
HasLyrics3Tag = GetLyrics3Tag(True)
If HasLyrics3Tag Then m_TagType = m_TagType Or Lyrics3Tag
End If
'everything should be closed, but make sure
Close
'if no tags, then get info from filename
If m_TagType = NoTag Then
GetInfoFromFileName
End If
m_fValidFile = True
RaiseEvent ReadComplete
Exit Sub
Hell:
Close
End SubPrivate Function GetID3v2Tag(Tag2 As String) As Boolean
'decifer the tag
'we cheat here as we are only interested in certain fields
'we only look for those and ignore everything else
Dim TitleField As String
Dim ArtistField As String
Dim AlbumField As String
Dim YearField As String
Dim GenreField As String
Dim FieldSize As Long
Dim SizeOffset As Long
Dim FieldOffset As Long
On Error GoTo Hell
Select Case Version
Case 2
'set the fieldnames for version 2.0
TitleField = "TT2"
ArtistField = "TOA"
AlbumField = "TAL"
YearField = "TYE"
GenreField = "TCO"
FieldOffset = 7
SizeOffset = 5
Case 3
'set the fieldnames for version 3.0
TitleField = "TIT2"
ArtistField = "TOPE"
AlbumField = "TALB"
YearField = "TYER"
GenreField = "TCON"
FieldOffset = 11
SizeOffset = 7
Case Else
'not a valid tag, exit
Exit Function
End Select
i = InStr(Tag2, TitleField)
If i > 0 Then
'read the title
FieldSize = Asc(Mid$(Tag2, i + SizeOffset)) - 1
If Version = 3 Then
'check for compressed or encrypted field
B = Asc(Mid$(Tag2, i + 9))
If (B And 128) = True Or (B And 64) = True Then GoTo ReadAlbum
End If
m_sTitle = Mid$(Tag2, i + FieldOffset, FieldSize)
End If
ReadAlbum:
i = InStr(Tag2, AlbumField)
If i > 0 Then
FieldSize = Asc(Mid$(Tag2, i + SizeOffset)) - 1
If Version = 3 Then
'check for compressed or encrypted field
B = Asc(Mid$(Tag2, i + 9))
If (B And 128) = 128 Or (B And 64) = 64 Then GoTo ReadArtist
End If
m_sAlbum = Mid$(Tag2, i + FieldOffset, FieldSize)
End If
ReadArtist:
i = InStr(Tag2, ArtistField)
If i > 0 Then
FieldSize = Asc(Mid$(Tag2, i + SizeOffset)) - 1
If Version = 3 Then
'check for compressed or encrypted field
B = Asc(Mid$(Tag2, i + 9))
If (B And 128) = 128 Or (B And 64) = 64 Then GoTo ReadYear
End If
m_sArtist = Mid$(Tag2, i + FieldOffset, FieldSize)
End If
ReadYear:
i = InStr(Tag2, YearField)
If i > 0 Then
FieldSize = Asc(Mid$(Tag2, i + SizeOffset)) - 1
If Version = 3 Then
'check for compressed or encrypted field
B = Asc(Mid$(Tag2, i + 9))
If (B And 128) = 128 Or (B And 64) = 64 Then GoTo ReadGenre
End If
m_sYear = Mid$(Tag2, i + FieldOffset, FieldSize)
End If
ReadGenre:
i = InStr(Tag2, GenreField)
If i > 0 Then
FieldSize = Asc(Mid$(Tag2, i + SizeOffset)) - 1
If Version = 3 Then
'check for compressed or encrypted field
B = Asc(Mid$(Tag2, i + 9))
If (B And 128) = 128 Or (B And 64) = 64 Then GoTo Done
End If
s = Mid$(Tag2, i + FieldOffset, FieldSize)
If Left$(s, 1) = "(" Then
Genre = Val(Mid$(s, 2, 2))
Else
i = InStr(gsGenres, s & Space$(22 - Len(s)))
If i > 0 Then
Genre = Int(i / 22)
End If
End If
End If
Done:
GetID3v2Tag = True
Exit FunctionHell:
'invalid tag exit
End Function
Private Function GetLyrics3Tag(SaveInfo As Boolean) As Boolean
On Error GoTo Hell
Dim Position As Long
Dim FieldData As String
Dim FieldID As String * 3
Dim FSZ As Integer
Dim fn As Integer
Dim Size As Long
Dim TagType As String * 9
Dim Byte11Buffer As String * 11
Dim Byte5Buffer As String * 5
'reset size of tag
LSZ = "000000"
'open the file
fn = FreeFile
Open m_sFileName For Binary As #fn
'get filesize
Size = LOF(fn)
'get the tag END
Get #fn, Size - 136, TagType
'if tag is valid then
If TagType = "LYRICS200" Then
'get the size of the tag
Get #fn, Size - 142, LSZ
'set the position to the first byte
Position = Size - 142 - LSZ
'get the beginning of tag
Get #fn, Position, Byte11Buffer
If Byte11Buffer <> "LYRICSBEGIN" Then
'invalid Lyrics3 version 2 tag!
'we don't support version 1...
Close
Exit Function
End If
'first field
Position = Position + 11
'keep getting fields until we get to the end of the tag
Do Until Position >= Size - 142
'the field id
Get #fn, Position, FieldID
'the size of the field
Get #fn, Position + 3, Byte5Buffer
FSZ = Val(Byte5Buffer)
'make room for the data
FieldData = Space(FSZ)
'get the data
Get #fn, Position + 8, FieldData
'and fill the approprate field
Select Case FieldID
Case "LYR"
m_sLyrics = Trim$(FieldData)
Case "INF"
m_sOtherInfo = Trim$(FieldData)
Case "AUT"
m_sAuthor = Trim$(FieldData)
Case "EAL"
m_sAlbum = Trim$(FieldData)
Case "EAR"
m_sArtist = Trim$(FieldData)
Case "ETT"
m_sTitle = Trim$(FieldData)
Case "IMG"
m_sImages = Trim$(FieldData)
Case "QUA"
m_sQuality = Trim$(FieldData)
Case "SIT"
m_sSituation = Trim$(FieldData)
Case "MOO"
m_sMood = Trim$(FieldData)
Case Else
'must be something we don't know about, save it.
m_sUnknownFields = m_sUnknownFields & FieldID & Format(FSZ, "00000") & FieldData
End Select
'now set the postion to the beginning of the next field
Position = Position + 8 + FSZ
Loop
'set the flag
GetLyrics3Tag = True
End If
Exit Function
Hell:
'close all open files
Close
End Function
Public Sub Reset()
'Load Default values...
m_sTitle = sEmpty
m_sArtist = sEmpty
m_sAlbum = sEmpty
m_sYear = "2000"
m_sComment = sEmpty
m_Genre = 12
m_Duration = 0
m_BitRate = 0
m_Frequency = 0
m_TagType = NoTag
m_IsVBR = False
m_sLyrics = sEmpty
m_sQuality = sEmpty
m_sSituation = sEmpty
m_sMood = sEmpty
m_sAuthor = sEmpty
m_sOtherInfo = sEmpty
m_sImages = sEmpty
m_fValidFile = False
End SubPublic Function WriteTag() As Boolean
Dim WholeTag As String
Dim TagSize As String * 6
Dim Position As Long
Dim MoveMP3Tag As Boolean
Dim fn As Integer
Dim UseOldInfo As Boolean
Dim Tag1 As udtID3v1Tag
Dim NewLyr As Boolean
WholeTag = sEmpty
On Error GoTo Hell
If Len(m_sTitle) > 30 Then NewLyr = True
If Len(m_sArtist) > 30 Then NewLyr = True
If Len(m_sAlbum) > 30 Then NewLyr = True
If m_sAuthor <> sEmpty Then NewLyr = True
If m_sImages <> sEmpty Then NewLyr = True
If m_sOtherInfo <> sEmpty Then NewLyr = True
If m_sLyrics <> sEmpty Then NewLyr = True
If m_sMood <> sEmpty Then NewLyr = True
If m_sQuality <> sEmpty Then NewLyr = True
If m_sSituation <> sEmpty Then NewLyr = True
'build the tag
If NewLyr = True Then
WholeTag = "LYRICSBEGIN"
Dim IND As String
'the IND field is based on the Lyrics and tagtype. If there are no lyrics there is no IND field
'if the lyrcis are there, it is "10" if it also has timestamps it is "11"
'ID for tag
IND = "00"
If m_sLyrics <> sEmpty Then
IND = "10"
If InStr(1, m_sLyrics, ":") And InStr(1, m_sLyrics, "]") Then IND = "11"
End If
WholeTag = WholeTag & "IND00002" & IND
'lyrics
If m_sLyrics <> sEmpty Then
WholeTag = WholeTag & "LYR" & Format(Len(m_sLyrics), "00000") & m_sLyrics
End If
'other info
If m_sOtherInfo <> sEmpty Then
WholeTag = WholeTag & "INF" & Format(Len(m_sOtherInfo), "00000") & m_sOtherInfo
End If
'author
If m_sAuthor <> sEmpty Then
WholeTag = WholeTag & "AUT" & Format(Len(m_sAuthor), "00000") & m_sAuthor
End If
'album
If Len(m_sAlbum) > 30 Then
WholeTag = WholeTag & "EAL" & Format(Len(m_sAlbum), "00000") & m_sAlbum
End If
'artist
If Len(m_sArtist) > 30 Then
WholeTag = WholeTag & "EAR" & Format(Len(m_sArtist), "00000") & m_sArtist
End If
'title
If Len(m_sTitle) > 30 Then
WholeTag = WholeTag & "ETT" & Format(Len(m_sTitle), "00000") & m_sTitle
End If
'images
If m_sImages <> sEmpty Then
WholeTag = WholeTag & "IMG" & Format(Len(m_sImages), "00000") & m_sImages
End If
'quality
If m_sQuality <> sEmpty Then
WholeTag = WholeTag & "QUA" & Format(Len(m_sQuality), "00000") & m_sQuality
End If
'situation
If m_sSituation <> sEmpty Then
WholeTag = WholeTag & "SIT" & Format(Len(m_sSituation), "00000") & m_sSituation
End If
'mood
If m_sMood <> sEmpty Then
WholeTag = WholeTag & "MOO" & Format(Len(m_sMood), "00000") & m_sMood
End If
'append the unknown fields
WholeTag = WholeTag + m_sUnknownFields
'calcuate the size
TagSize = Format(Len(WholeTag), "000000")
'append the end identifier
WholeTag = WholeTag & TagSize & "LYRICS200"
End If
'prepare for writing
fn = FreeFile
Open m_sFileName For Binary As #fn
'set to just before the current id3 tag.
Position = LOF(fn) - 127
'if there is a Lyrics3 tag, then go back to the beginning of the old one
If HasLyrics3Tag Then Position = Position - 15 - Val(LSZ)
' write the lyrics3 tag if there is one...
If WholeTag <> sEmpty Then
Put #fn, Position, WholeTag
Position = Seek(fn)
End If
'make the ld3tag
Tag1.id = "TAG"
Tag1.Title = m_sTitle
Tag1.Artist = m_sArtist
Tag1.Album = m_sAlbum
Tag1.Comment = m_sComment
Tag1.Year = m_sYear
Tag1.Genre = m_Genre
'write the id3tag
Put #fn, Position, Tag1
'set the last byte of the file
Position = Seek(fn) - 1
Close
'make sure this is the end of the file which is needed if this tag is smaller than the old tag.
SetFileLength FileName, Position
RaiseEvent WriteComplete
Exit Function
Hell:
Mbox "WriteTags: Error " & Err.Description
End FunctionPrivate Sub SetFileLength(ByVal FileName As String, ByVal NewLength As Long)
'Will cut the length of a file to the length specified.
Dim hFile As Long
'if file is smaller than or equal to requsted length, exit.
If FileLen(FileName) <= NewLength Then Exit Sub
'open the file
hFile = CreateFile(FileName, GENERIC_WRITE, ZERO, ByVal ZERO, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0)
'if file not open exit
If hFile = -1 Then Exit Sub
'seek to position
L = SetFilePointer(hFile, NewLength, ZERO, ZERO)
'and here as end of file
SetEndOfFile hFile
'close the file
L = CloseHandle(hFile)
End SubPublic Sub GetInfoFromFileName()
Dim Marker As Integer
On Error GoTo Hell
'separate m_sFileName from Dir (common to all tag structures
i = InStrRev(m_sFileName, sBSlash)
s = Right$(m_sFileName, Len(m_sFileName) - i)
Marker = i - 1 'set er to be the last char before the sbslash
Select Case m_DirStructure
Case 0 ' No Structure
m_sTitle = s
m_sArtist = sEmpty
m_sAlbum = sEmpty
Case 1 ' artist\album\title
m_sTitle = Left$(s, Len(s) - 4) 'take off the .mp3
i = InStrRev(m_sFileName, sBSlash, Marker)
m_sAlbum = Mid$(m_sFileName, i + 1, Marker - i)
Marker = i - 1 'set er to last char before sbslash again
i = InStrRev(m_sFileName, sBSlash, Marker)
m_sArtist = Mid$(m_sFileName, i + 1, Marker - i)
Case 2 'artist\title
'same as above, only one less loop
m_sTitle = Left$(s, Len(s) - 4)
i = InStrRev(m_sFileName, sBSlash, Marker)
m_sArtist = Mid$(m_sFileName, i + 1, Marker - i)
m_sAlbum = sEmpty
Case 3 ' Artist - Title ... this may not always work...
s = Left$(s, Len(s) - 4) 'remove extension
i = InStr(s, sDash)
m_sTitle = Right$(s, Len(s) - (i + 2))
m_sArtist = Left$(s, i - 1)
m_sAlbum = sEmpty
Case 4 'Title - Artist
s = Left$(s, Len(s) - 4)
i = InStr(s, sDash)
m_sArtist = Right$(s, Len(s) - (i + 2))
m_sTitle = Left$(s, i - 1)
m_sAlbum = sEmpty
End Select
Hell:
End SubPublic Property Get DirStructure() As EDirStructure
DirStructure = m_DirStructure
End PropertyPublic Property Let DirStructure(NewDirStructure As EDirStructure)
m_DirStructure = NewDirStructure
End PropertyPrivate Function CheckMid()
'This function cheats! Remove it before trying to use this class
'in another program. It uses variables from other parts of the
'program! Make sure you also remove the call to this function.
On Error GoTo Hell
Set DXPlayer = New FilgraphManager
Set DXPlayerPosition = DXPlayer
'we use the player to calculate the duration of the midi file
DXPlayer.RenderFile m_sFileName
m_Duration = DXPlayerPosition.Duration
'and get the other info from the filename, as midis can't have tags
GetInfoFromFileName
m_fValidFile = True
Hell:
Set DXPlayerPosition = Nothing
Set DXPlayer = Nothing
End Function
[email protected]
[email protected]