先简单说一下MP3的ID3 标记,因为主要是操作这个玩意
MP3最开始的时候没有我们今天看到的那样,有歌手、年代,专集等等信息
只有一些简单的参数如yes/no来表示是不是privated或者copyrighted等信息,这样对MP3的相关工作带来了很多不便,1996年的时候有个老外提出来在每个MP3后面追加一段数据,用以存放上述的那些信息,后来就发展成为id3 v1 据我所知的现在已经到1.1了,具体的还是自己去查一下吧
还是老习惯,用metadata来引入DLL,我以前有文章贴过的,不知道的请自己去查
看代码
1
2Function ConvertBin(Binary)
3'This function converts a binary byte into an ASCII byte.
4for i = 1 to LenB(Binary)
5strChar = chr(AscB(MidB(Binary,i,1)))
6ConvertBin = ConvertBin & strChar
7Next
8End Function
9
10dim objStream
11dim strTag, strSongName, strArtist, strAlbum, strYear, _
12strComment, strGenre, strFile
13
14'Specify the folder to iterate through, displaying all the MP3s
15Const folder = "C:\mp3s\"
16
17'Grab the folder information
18
19Dim objFSO, objFolder, objFile
20Set objFSO = Server.CreateObject("Scripting.FileSYstemObject")
21Set objFolder = objFSO.GetFolder(folder)
22
23'Create the Stream object
24set objStream = Server.CreateObject("ADODB.Stream")
25objStream.Type = adTypeBinary
26
27'Loop through the files in the folder
28For Each objFile in objFolder.Files
29'Open the stream
30objStream.Open
31objStream.LoadFromFile objFile.Path
32
33'Read the last 128 bytes
34objStream.Position = objStream.size - 128
35
36'Read the ID3 v1 tag info
37strTag = ConvertBin(objStream.Read(3))
38if ucase(strTag) = "TAG" then
39strSongName = ConvertBin(objStream.Read(30))
40strArtist = ConvertBin(objStream.Read(30))
41strAlbum = ConvertBin(objStream.Read(30))
42strYear = ConvertBin(objStream.Read(4))
43strComment = ConvertBin(objStream.Read(30))
44end if
45
46'Display the results
47response.write "
<table><tr><td colspan="2"><h3>" & _
"ID3 Tag info for:</h3></td></tr><tr>" & _
"<td colspan="2">" & objFile.Name & "</td></tr>"
response.write "<tr><td><b>Artist: </b></td>" & _
"<td>" & strArtist & "</td></tr>"
response.write "<tr><td><b>Track: </b></td>" & _
"<td>" & strSongName & "</td></tr>"
response.write "<tr><td><b>Album: </b></td>" & _
<td>" & strAlbum & "</td></tr>"
response.write "<tr><td><b>Year: </b></td>" & _
"<td>" & strYear & "</td></tr>"
response.write "<tr><td><b>Comment: </b>" & _
"</td><td>" & strComment & "</td></tr>"
response.write "</table>
1"
2
3objStream.Close
4
5Response.Write "
<p><hr/><p>"
Next
Set objStream = Nothing 'Clean up...
1
2自己试试吧
3
4希望能对你有所帮助</p></p>