Use. Net to read Flash format file information

Source: Internet
Author: User

There has always been such a problem, that is, when you upload a flash file, the width and height of the input flash must be included; otherwise, the ratio of the flash is abnormal because you do not know these values.

Recently, my website also involves this problem, so I plan to solve it.

First, search on Google to find the JavaScript code for obtaining the flash width and height, but it is not before the flash is loaded, and the width and height of the object tag cannot be dynamically changed, the most important thing is that there is Flash Player's security warning information, so I gave up reading on the client and turned to the server.

Import flash in. the OCX control tries to obtain the Flash file information. The result of calling the tgetproperty () method is always to return the e_fail error and fails. net.

There is only one method left, and the most feasible method is to directly read The Flash file and analyze the format.

Search on GoogleMacromedia Flash (SWF) File Format Specification Version 7Http://www.xiaowowo.com/gt_book/new/flashfileformat.rar)

After reading and trying again, I finally wrote the flashinfo class. The Calling method is as follows:

Flashinfo =   New Flashinfo ( @" C: \ test.swf " ); // Constructor. The parameter is the flash file address.
Console. writeline ( String . Format ( " Version: {0} " , Flashinfo. Version); // flash version
Console. writeline ( String . Format ( " Compressed: {0} " , Flashinfo. iscompressed); // whether it is compressed
Console. writeline ( String . Format ( " Width: {0} " , Flashinfo. width); // flash width
Console. writeline ( String . Format ( " Height: {0} " , Flashinfo. Height); // flash height
Console. writeline ( String . Format ( " Framerate: {0} " , Flashinfo. framerate); // Frame Rate
Console. writeline ( String . Format ( " Framecount: {0} " , Flashinfo. framecount); // The total number of frames.
Console. writeline ( String . Format ( " Filelength: {0} " , Flashinfo. filelength); // file size when not compressed

Since the Flash format version 6, added the compression option, with zlib compression, in order to support the compression format, had to find a zlib. Net wrapper (http://zlibnetwrapper.sourceforge.net/) on Google /)

Flashinfo classSource codeAnd compiled library files provided to friends who have the same needs download: http://files.cnblogs.com/gmm/FlashInfo.zip

The level is limited, and the shortcomings are inevitable. please correct me!

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.