<! -- Metadata type = "typelib"
UUID = "00000205-0000-0010-8000-00aa006d2ea4"
Name = "ADODB Type Library"
-->
<%
'Author: Long zyvslxl, zyvslxl@163.com please keep
'The attribute to be specified
'Path file path
'The Class header defines the property to get information. Of course, it can return any tag value theoretically.
'Add a known tag to the select case frameid (I) Part of ID3v2 () to return the corresponding content.
'If you have limited personal knowledge, please advise
'Available Methods
'Createstream open the file stream
'Pre execution
'Closestream closes the file stream
Class MP3
Public path
Public flag
Public title' title
Public artist 'author
Public album 'album
Public issueyear
Public Comment 'Remarks
Public genre' type
Public tcon
Public mptime' time
Public uslt 'lyrics
Private objstream
'[To be extended]
Private function exitext ()
Dim ext
EXT = lcase (right (path, Len (PATH)-limit Rev (".")))
Exitext = ext
End Function
'[Conversion function, some types still cannot be determined]
Private function bin2str (binstr, num)
On Error resume next
Dim varlen, Clow, CCC, skipflag, I, biy
Skipflag = 0
CCC = ""
For I = 1 to num
Clow = midb (binstr, I, 1)
If ASCB (Clow) = 0 then
Skipflag = 0
'Ccc = NULL
Else
If skipflag = 0 then
If ASCB (Clow)> 127 then
CCC = CCC & CHR (ASCW (midb (binstr, I + 1, 1) & Clow ))
Skipflag = 1
Else
CCC = CCC & CHR (ASCB (Clow ))
End if
Else
Skipflag = 0
End if
End if
Next
Bin2str = ccc
End Function
'[Load file]
Public Function createstream ()
On Error resume next
Set objstream = server. Createobject ("ADODB. Stream ")
Objstream. type = adtypebinary
Objstream. Open
Err. Clear
Objstream. loadfromfile path
If err <> 0 then
Objstream. loadfromfile server. mappath (PATH)
End if
Err. Clear
End Function
'[Close file stream]
Public Function closestream ()
Objstream. Close
Set objstream = nothing
End Function
'[Flag Information]
Public Function ID ()
Dim comm
Objstream. Position = 0
Comm = objstream. Read (3)
Id = bin2str (Comm)
End Function
'[Read ID3v2 Information]
Private function ID3v2 ()
Dim frameid ()
Dim framesize ()
Dim framesize1 ()
Dim flags ()
Dim frame ()
Dim maxsize
Dim I
I = 0
Objstream. Position = 6
Maxsize = topsize (objstream. Read (4 ))
'Response. Write "<font color = Red>" & maxsize & "</font> <br>"
Do While objstream. Position <maxsize
Redim preserve frameid (I), framesize (I), framesize1 (I), flags (I), frame (I)
Frameid (I) = bin2str (objstream. Read (4), 4)
If isnull (frameid (I) or frameid (I) = "" Then exit do
Framesize (I) = size (objstream. Read (4 ))
If isnull (framesize (I) or framesize (I) = 0 Then exit do
Objstream. Read (2) '[flag]
'Objstream. Read (1)
Frame (I) = bin2str (objstream. Read (framesize (I), framesize (I ))
I = I + 1
Loop
'[Assign values to attributes in sequence]
Dim J
J = I-1
For I = 0 to J
'Response. Write I
Select case ucase (frameid (I ))
Case "tit2": Title = CSTR (frame (I ))
Case "Comm": Comment = CSTR (frame (I ))
Case "tpe1": artist = CSTR (frame (I ))
Case "talb": album = CSTR (frame (I ))
Case "tyer": issueyear = CSTR (frame (I ))
Case "tcon": tcon = CSTR (frame (I ))
Case "time": mptime = CSTR (frame (I ))
Case "uslt": uslt = CSTR (frame (I ))
End select
Next
End Function
'[Get the tag frame length/the length of a specific TAG content]
Private function size (Num)
Size = NULL
Dim a, B, c, d
A = midb (Num, 1, 1)
B = midb (Num, 2, 1)
C = midb (Num, 3, 1)
D = midb (Num, 4, 1)
If not isnull (a) then
Size = ASCB (a) * 4294967296
End if
If not isnull (B) then
Size = size + ASCB (B) * 65536
End if
If not isnull (c) then
Size = size + ASCB (c) * 256
End if
If not isnull (d) then
Size = size + ASCB (d)
End if
End Function
'[Obtain the length of the header tag/The total length of the tag]
Private function topsize (Num)
Topsize = NULL
Dim a, B, c, d
A = midb (Num, 1, 1)
B = midb (Num, 2, 1)
C = midb (Num, 3, 1)
D = midb (Num, 4, 1)
If not isnull (a) then
Topsize = ASCB (a) * 2097152
End if
If not isnull (B) then
Topsize = topsize + ASCB (B) * 1024
End if
If not isnull (c) then
Topsize = topsize + ASCB (c) * 128
End if
If not isnull (d) then
Topsize = topsize + ASCB (d)
End if
End Function
'[Read id3v1 Information]
Private function id3v1 ()
Objstream. Position = objstream. Size-128
Flag = bin2str (objstream. Read (3), 3)
If flag = "tag" then
Title = bin2str (objstream. Read (30), 30)
Artist = bin2str (objstream. Read (30), 30)
Album = bin2str (objstream. Read (30), 30)
Issueyear = bin2str (objstream. Read (4), 4)
Comment = bin2str (objstream. Read (30), 30)
Genre = bin2str (objstream. Read (3), 3)
End if
End Function
'[Identify id3v1 and ID3v2 only]
Private function fileflag ()
Objstream. Position = 0
Dim flag
Flag = ucase (bin2str (objstream. Read (3), 3 ))
If flag = "ID3" then fileflag = true
'Response. Write flag & "<br>"
End Function
'[ID3v2 version information is returned first]
Public Function pre ()
If fileflag then
ID3v2
Else
Id3v1
End if
End Function
End Class
%>