一个可以读取ID3信息的类[可以很方便添加MP3了][1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 zyvslxl 的 blog

<!--metadata type="typelib"
      uuid="00000205-0000-0010-8000-00aa006d2ea4"
     name="adodb type library"
-->
<%
'author: 小龙 zyvslxl,zyvslxl@163.com 请保留
'需指定的属性
'path           文件的路径

'类头部分定义的属性为可以得到信息,当然不止这个,理论上可以返回任何标签值
'在id3v2() 中的select case frameid(i)部分加入已知的标签,可以返回相应的内容
'因为个人知识有限,会的话请指教


'可用方法
'createstream   打开文件流
'pre            执行
'closestream    关闭文件流

class mp3

public path
public flag
public title          '标题
public artist         '作者
public album          '专集
public issueyear      '出品年代
public comment        '备注
public genre          '类型
public tcon           '流派
public mptime         '时间
public uslt           '歌词
private objstream


'[待扩展]
private function exitext()
       dim ext
       ext = lcase(right(path,len(path)-instrrev(".")))
    exitext = ext
end function


'[转换函数,有些类型还是判断不了]
private function bin2str(binstr,num)
on error resume next
    dim varlen,clow,ccc,skipflag ,i,biy
    skipflag=0
    ccc = ""
        for i=1 to num
            clow = midb(binstr,i,1)
     if ascb(clow)=0 then
                 skipflag=0
    ' ccc = null
     else
                if skipflag=0 then
                     if ascb(clow) > 127 then
                         ccc =ccc & chr(ascw(midb(binstr,i+1,1) & clow))
                         skipflag=1
                     else
                         ccc = ccc & chr(ascb(clow))
                     end if
               else
                     skipflag=0
               end if
   
    end if
       next
    bin2str = ccc
end function


'[载入文件]
public function createstream()
       on error resume next
       set objstream = server.createobject("adodb.stream")
       objstream.type = adtypebinary
       objstream.open
    err.clear
    objstream.loadfromfile path
    if err<>0 then
              objstream.loadfromfile server.mappath(path)
    end if
    err.clear
end function

'[关闭文件流]
public function closestream()
      objstream.close
      set objstream = nothing
end function


'[标志信息]
public function id()
       dim comm
       objstream.position =0
       comm = objstream.read(3)
    id = bin2str(comm)
end function


'[id3v2信息读取]
private function id3v2()
        dim frameid()
  dim framesize()

本文关键:一个可以读取ID3信息的类[可以很方便添加MP3了]
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top