Using ASP to realize the operation of MP3 track information

Source: Internet
Author: User
Tags id3 id3 tag


Let's say a little bit about MP3 's ID3, because it's mainly about manipulating this thing.



MP3 at the very beginning without what we see today, there are singers, times, albums and so on.



Only a few simple parameters such as yes/no to express is not privated or copyrighted information, so that MP3 related to the work caused a lot of inconvenience, 1996 when a foreigner proposed to each of the MP3 appended a piece of data to store the above information, And then it developed into a ID3 v1. As far as I know, it's 1.1 now.



Or the old habit, with metadata to introduce the DLL, I used to have articles posted, do not know please check yourself



Look at the code


!--METADATA type= "TypeLib"
Uuid= "00000205-0000-0010-8000-00AA006D2EA4"
Name= "ADODB Type Library"
--〉
〈%
Function Convertbin (Binary)
' This function converts a binary byte to 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 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 ' 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〉〈h3〉" & _
"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〉〈hr〉〈p〉"
Next
Set objstream = Nothing ' clean up ...
%〉


Try it yourself.



I wish I could be of some help to you.


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.