这是我写的第一个读取文件信息的代码,好像是05年写的. 当时只会asp。写好后才发现性能不是一般的低
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Option Explicit
Response.Buffer = False
server.ScriptTimeout = 3600000
Class Mp3WmaInfo
Private Info
Private Stream
Private Standard_Wma_Header
Private Standard_Wma_Tag_Header
Private Standard_Wma_ExTag_Header
Private Standard_Mp3_ID3V2Tag_Header
Private TagCoding,Mp3_Genres(147)
Public Function GetTag(Path,Input_TagCoding)
Set Info = Server.CreateObject("Scripting.Dictionary")
Set Stream = Server.CreateObject("Adodb.Stream")
Dim Temp_Index
Dim Hex_String
Stream.Type = 1
Stream.Mode = 3
Stream.Open
Stream.Position = 0
Stream.LoadFromFile Path
TagCoding = Input_TagCoding
If TagCoding = "" Then TagCoding = "Unicode" End If
For Temp_Index = 1 To 16
Hex_String = Hex_String & Hex(AscB(Stream.Read(1)))
Next
If Hex_String = Standard_Wma_Header Then
Call GetWmaInfo()
Else
Call GetMp3Info()
End If
Stream.Close
Set Stream = NoThing
Set GetTag = Info
End Function
Private Sub GetMp3Info()
Dim Temp_Index
Dim Hex_String
Stream.Position = 0
For Temp_Index = 1 To 3
Hex_String = Hex_String & Hex(AscB(Stream.Read(1)))
Next
If Hex_String = Standard_Mp3_ID3V2Tag_Header Then
Set Info.Item("ID3V2") = Server.CreateObject("Scripting.Dictionary")
Dim ID3V2_Temp_Size(3)
Dim ID3V2_Size
Dim ID3V2_Flag
Dim ID3V2_Temp_FrameSize(3)
Dim ID3V2_FrameID
Dim ID3V2_FrameSize
Dim ID3V2_FrameSizeFlags
Dim ID3V2_FrameContent
Info.Item("ID3V2").Item("Ver") = AscB(Stream.Read(1))
Info.Item("ID3V2").Item("Revision") = AscB(Stream.Read(1))
ID3V2_Flag = AlgorismToBinary(AscB(Stream.Read(1)),8)
ID3V2_Temp_Size(0) = AscB(Stream.Read(1)) * 2097152
ID3V2_Temp_Size(1) = AscB(Stream.Read(1)) * 16384
ID3V2_Temp_Size(2) = AscB(Stream.Read(1)) * 128
ID3V2_Temp_Size(3) = AscB(Stream.Read(1))
ID3V2_Size = ID3V2_Temp_Size(0) + ID3V2_Temp_Size(1) + ID3V2_Temp_Size(2) + ID3V2_Temp_Size(3)
While Stream.Position <= ID3V2_Size
ID3V2_FrameID = Trim(ByteToText(Stream.Read(4),TagCoding))
ID3V2_Temp_FrameSize(0) = AscB(Stream.Read(1)) * 16777216
ID3V2_Temp_FrameSize(1) = AscB(Stream.Read(1)) * 65536
ID3V2_Temp_FrameSize(2) = AscB(Stream.Read(1)) * 256
ID3V2_Temp_FrameSize(3) = AscB(Stream.Read(1))
ID3V2_FrameSize = ID3V2_Temp_FrameSize(0) + ID3V2_Temp_FrameSize(1) + ID3V2_Temp_FrameSize(2) + ID3V2_Temp_FrameSize(3)
ID3V2_FrameSizeFlags = AlgorismToBinary(AscB(Stream.Read(1)),8)
ID3V2_FrameSizeFlags = ID3V2_FrameSizeFlags & AlgorismToBinary(AscB(Stream.Read(1)),8)
If ID3V2_FrameSize <> 0 Then
ID3V2_FrameContent = Trim(ByteToText(Stream.Read(ID3V2_FrameSize),TagCoding))
End If
If ID3V2_FrameID <> "" AND (ID3V2_FrameSizeFlags = "0000000000000000" OR ID3V2_FrameSizeFlags = "0010000000000000") Then
Info.Item("ID3V2").Item(ID3V2_FrameID) = ID3V2_FrameContent
End If
Wend
End If
Stream.Position = Stream.Size - 128
If ByteToText(Stream.Read(3),TagCoding) = "TAG" Then
Dim Mp3_ID3v1_Cenre,Mp3_ID3v1_Cenre_Index
Set Info.Item("ID3v1") = Server.CreateObject("Scripting.Dictionary")
Info.Item("ID3v1").Item("Title") = ByteToText(Stream.Read(30),TagCoding)
Info.Item("ID3v1").Item("Artist") = ByteToText(Stream.Read(30),TagCoding)
Info.Item("ID3v1").Item("Album") = ByteToText(Stream.Read(30),TagCoding