Use ASP to operate MP3 tracks

Source: Internet
Author: User
Tags id3 id3 tag

Let's briefly talk about the ID3 mark of MP3, because it is mainly used to perform this operation.

At the very beginning, MP3 didn't have the information we saw today, such as singers, ages, and albums.

Only some simple parameters such as yes/no are used to indicate whether it is privated or copyrighted, which makes it inconvenient for MP3-related work, in 1996, a foreigner proposed to append a piece of data to each MP3 file to store the above information. Later, it developed into id3 v1, which is now 1.1 as far as I know, check the details by yourself.

I still get used to using metadata to introduce DLL. I have posted some articles before. If you do not know, please check it yourself.

View code

<! -- Metadata type = "typelib"

UUID = "00000205-0000-0010-8000-00AA006D2EA4"

NAME = "ADODB Type Library"

-->

<%

Function ConvertBin (Binary)

'This function converts a binary byte into an ASCII byte.

For I = 1 to LenB (Binary)

StrChar = chr (AscB (MidB (Binary, I, 1 )))

ConvertBin = ConvertBin & strChar

Next

End Function

Dim objStream

Dim strTag, strSongName, strArtist, strAlbum, strYear ,_

StrComment, strGenre, strFile

'Specify the folder to iterate through, displaying all the MP3s

Const folder = "C: \ mp3s \"

'Grab the folder information

Dim objFSO, objFolder, objFile

Set objFSO = Server. CreateObject ("Scripting. FileSYstemObject ")

Set objFolder = objFSO. GetFolder (folder)

'Create the Stream object

Set objStream = Server. CreateObject ("ADODB. Stream ")

ObjStream. Type = adTypeBinary

'Loop through the files in the folder

For Each objFile in objFolder. Files

'Open the stream

ObjStream. Open

ObjStream. LoadFromFile objFile. Path

'Read the last 128 bytes

ObjStream. Position = objStream. size-128

'Read the ID3 v1 tag info

StrTag = ConvertBin (objStream. Read (3 ))

If ucase (strTag) = "TAG" then

StrSongName = ConvertBin (objStream. Read (30 ))

StrArtist = ConvertBin (objStream. Read (30 ))

StrAlbum = ConvertBin (objStream. Read (30 ))

StrYear = ConvertBin (objStream. Read (4 ))

StrComment = ConvertBin (objStream. Read (30 ))

End if

'Display the results

Response. write "<table> <tr> <td colspan = 2>
"ID3 Tag info for: </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>"

ObjStream. Close

Response. Write "<p>
Next

Set objStream = Nothing 'clean up...

%>

Try it by yourself

Hope to help you

Http://www.sanchat.com

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.