欢迎光临
我们一直在努力

用ASP实现对MP3曲目信息的操作

建站超值云服务器,限时71元/月

先简单说一下mp3的id3 标记,因为主要是操作这个玩意

mp3最开始的时候没有我们今天看到的那样,有歌手、年代,专集等等信息

只有一些简单的参数如yes/no来表示是不是privated或者copyrighted等信息,这样对mp3的相关工作带来了很多不便,1996年的时候有个老外提出来在每个mp3后面追加一段数据,用以存放上述的那些信息,后来就发展成为id3 v1 据我所知的现在已经到1.1了,具体的还是自己去查一下吧

还是老习惯,用metadata来引入dll,我以前有文章贴过的,不知道的请自己去查

看代码

<!–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><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…

%>

自己试试吧

希望能对你有所帮助

http://www.sanchat.com

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用ASP实现对MP3曲目信息的操作
分享到: 更多 (0)