Click here to Skip to main content
13,152,321 members (39,926 online)
Click here to Skip to main content
Add your own
alternative version

Stats

92K views
2.3K downloads
30 bookmarked
Posted 10 Aug 2007

Reader of SWF Header File in Pure C#

, 10 Aug 2007
Rate this:
Please Sign up or sign in to vote.
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

zebulon75018
Software Developer (Senior) http://www.cmb-soft.com/
France France
No Biography provided

You may also be interested in...

Comments and Discussions

 
QuestionHow does it handle garbage collection i cant dispose reader object Pin
inamul9-Dec-12 19:12
memberinamul9-Dec-12 19:12 
AnswerRe: How does it handle garbage collection i cant dispose reader object Pin
zebulon750187-May-13 9:09
memberzebulon750187-May-13 9:09 
GeneralMy vote of 5 Pin
manoj kumar choubey26-Feb-12 21:12
membermanoj kumar choubey26-Feb-12 21:12 
NewsCode Snipped to implement Duration Pin
Horst Klein24-Nov-11 0:59
memberHorst Klein24-Nov-11 0:59 
Questioninfo shown are totally off Pin
Member 842930423-Nov-11 22:53
memberMember 842930423-Nov-11 22:53 
GeneralMy Vote of 5 Pin
Alan Burkhart11-Jun-11 6:12
memberAlan Burkhart11-Jun-11 6:12 
GeneralRe: My Vote of 5 Pin
zebulon750187-May-13 9:07
memberzebulon750187-May-13 9:07 
GeneralMy vote of 1 Pin
gunjan9um13-Jul-09 1:36
membergunjan9um13-Jul-09 1:36 
GeneralMy vote of 1 Pin
crayzeecoder25-Jun-09 21:45
membercrayzeecoder25-Jun-09 21:45 
GeneralRead FLV and Real Media file meta data Pin
Vishal Dedaniya22-Dec-08 10:42
memberVishal Dedaniya22-Dec-08 10:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170924.2 | Last Updated 10 Aug 2007
Article Copyright 2007 by zebulon75018
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid