Introduction
It's my first article on The Code Project. Please excuse my English.
This article describes how to read the header of the flash file. (This file has the extension .swf )
The Format Header SWF is described in this link.
You can also read a good article on SWF which describes the library SwfDotNet.
I wrote this article for myself and for people who want small source code.
To read this header, I translate PHP code to C#. The original source code in PHP is at this address.
This is the code of a class which can provide information of the Swf Flash:
FrameRate
FrameCount
Width
Height
Version
Warning, this class doesn't work with the compressed Flash File.
Using the Code
The name of the class is FlashHeaderReader
and takes for the constructor a parameter, the filename of the flash file.
It calls these methods:
ReadSignature();
mVersion=GetNextByte();
ReadFileLength();
ReadFrameSize();
ReadFrameRate();
ReadFrameCount();
Later, you can access the properties of the swf file :
FlashHeaderReader swfreader = new FlashHeaderReader(openFileDialog1.FileName);
listBox1.Items.Clear();
listBox1.Items.Add("Frames : " + swfreader.FrameCount);
listBox1.Items.Add("Width : " + swfreader.Width );
listBox1.Items.Add("Height : " + swfreader.Height);
Points of Interest
The method ReadFrameSize
is complex because the swf format also compresses the header and information has a different size.
History
- 10th August, 2007: Initial post
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.