Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Reader of SWF Header File in Pure C#

0.00/5 (No votes)
10 Aug 2007 4  
Reader of SWF header file in pure C# with a single class
Screenshot - SwfHeaderReader.jpg

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

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here