新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 软件开发 > Web开发 > Asp教程 > 正文:在asp文件中访问flash详细信息

在asp文件中访问flash详细信息

新客网 XKER.COM 2003-07-11 来源: 收藏本文
<%

Class SWFDump

  Private header
  Private RECTdata
  Private nBits
  Private mversion
  Private mfilelen
  Private mxMin
  Private mxMax
  Private myMin
  Private myMax
  Private mheigt
  Private mwidth
  Private mframerate
  Private mframecount

  Private Sub Class_Initialize()

  End Sub

  Private Sub Class_Terminate()

  End Sub


  Private Function ReadHeader (filename)
     Const ForReading = 1, ForWriting = 2, ForAppending = 8
     Dim fso, f
     Set fso = CreateObject("Scripting.FileSystemObject")
     Set f = fso.OpenTextFile(filename, ForReading)
     ReadHeader = f.Read(21)
  End Function

  Private Function ToBin(inNumber, OutLenStr )
    Dim binary
    binary = ""
    do while inNumber >= 1
      binary = binary & inNumber mod 2
      inNumber = inNumber \ 2
    loop
    binary = binary & String(OutLenStr - len(binary), "0")
    ToBin = StrReverse(binary)
  End Function

  Private Function Bin2Decimal(inBin)
    Dim counter
    Dim temp
    Dim Value
    inBin = StrReverse(inBin)
    temp = 0
    For counter = 1 to Len(inBin)
      If counter = 1 then
        Value = 1
      Else
        Value = Value  * 2
      End If
      temp = temp + mid(inBin, counter ,1)  *  Value
    Next
    Bin2Decimal = temp
  End Function

  Public Function SWFDump(fileName)

    header = ReadHeader (fileName)
    mversion = asc(mid(header,4,1))
    mfilelen = asc(mid(header,5,1))
    mfilelen = mfilelen + asc(mid(header,6,1)) * 256
    mfilelen = mfilelen + asc(mid(header,7,1)) * 256 * 256
    mfilelen = mfilelen + asc(mid(header,8,1)) * 256 * 256 * 256

    RECTdata = ToBin(asc(mid(header,9,1)),8)
    RECTdata = RECTdata & ToBin(asc(mid(header,10,1)),8)
    RECTdata = RECTdata & ToBin(asc(mid(header,11,1)),8)
    RECTdata = RECTdata & ToBin(asc(mid(header,12,1)),8)
    RECTdata = RECTdata & ToBin(asc(mid(header,13,1)),8)
    RECTdata = RECTdata & ToBin(asc(mid(header,14,1)),8)
    RECTdata = RECTdata & ToBin(asc(mid(header,15,1)),8)
    RECTdata = RECTdata & ToBin(asc(mid(header,16,1)),8)
    RECTdata = RECTdata & ToBin(asc(mid(header,17,1)),8)

    nBits = Mid(RECTdata,1,5)
    nBits = Bin2Decimal(nBits)

    mxMin =  Bin2Decimal(Mid(RECTdata,6,nBits))
    mxMax =  Bin2Decimal(Mid(RECTdata,6 + nBits * 1 ,nBits))
    myMin =  Bin2Decimal(Mid(RECTdata,6 + nBits * 2 ,nBits))
    myMax =  Bin2Decimal(Mid(RECTdata,6 + nBits * 3 ,nBits))

    mheigt = (myMax - myMin) / 20
    mwidth = (mxMax - mxMin) / 20

    mframerate = asc(mid(header,18,1))

    mframecount = asc(mid(header,19,1))
    mframecount = mframecount + asc(mid(header,20,1)) * 256

  End Function


  Public Property Get Heigt()
    Heigt = mheigt
  End Property

  Public Property Get Width()
    Width = mwidth
  End Property

  Public Property Get Version()
    Version = mversion
  End Property

  Public Property Get FileLen()
    FileLen = mfilelen
  End Property

  Public Property Get xMin()
    xMin = mxMin
  End Property

  Public Property Get xMax()
    xMax = mxMax
  End Property

  Public Property Get yMin()
    yMin = myMin
  End Property

  Public Property Get yMax()
    yMax = myMax
  End Property

  Public Property Get Framerate()
    Framerate = mframerate
  End Property

  Public Property Get Framecount()
    Framecount = mframecount
  End Property
End Class
%>

做成包含文件swfheaderdump.inc
调用:

<!-- #include file="swfheaderdump.inc" -->
<%
' Pass the SWF name in querystring this way
' swfdump.asp?swf=yourmovie.swf
    
  set myObj = new swfdump
  myObj.SWFDump (Server.MapPath(request("swf")))
    
  Response.Write "Heigt (pixel)     = " & myObj.Heigt      & "<br>"
  Response.Write "Width (pixel)     = " & myObj.Width      & "<br>"
  Response.Write "Version           = " & myObj.Version    & "<br>"
  Response.Write "FileLen (bytes)   = " & myObj.FileLen    & "<br>"
  Response.Write "xMin (twips)      = " & myObj.xMin       & "<br>"
  Response.Write "xMax (twips)      = " & myObj.xMax       & "<br>"
  Response.Write "yMin (twips)      = " & myObj.yMin       & "<br>"
  Response.Write "yMax (twips)      = " & myObj.yMax       & "<br>"
  Response.Write "FrameRate         = " & myObj.FrameRate  & "<br>"
  Response.Write "FrameCount        = " & myObj.FrameCount & "<br>"
%>


收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐