Displaying Flash content in a C# WinForms application

FryHard picture FryHard · Aug 4, 2008 · Viewed 36.5k times · Source

What is the best way to display Flash content in a C# WinForms application? I would like to create a user control (similar to the current PictureBox) that will be able to display images and flash content.

It would be great to be able to load the flash content from a stream of sorts rather than a file on disk.

Answer

sven picture sven · Aug 4, 2008

While I haven't used a flash object inside a windows form application myself, I do know that it's possible. In Visual studio on your toolbox, choose to add a new component. Then in the new window that appears choose the "COM Components" tab to get a list in which you can find the "Shockwave Flash Object"

Once added to the toolbox, simply use the control as you would use any other "standard" control from visual studio.

three simple commands are available to interact with the control:

  • AxShockwaveFlash1.Stop()
  • AxShockwaveFlash1.Movie = FilePath & "\FileName.swf"
  • AxShockwaveFlash1.Play()

which, I think, are all self explanatory.

It would be great to be able to load the flash content from a stream of sorts rather than a file on disk.

I just saw you are also looking for a means to load the content from a stream, and because I'm not really sure that is possible with the shockwave flash object I will give you another option (two actually).

the first is the one I would advise you to use only when necessary, as it uses the full blown "webbrowser component" (also available as an extra toolbox item), which is like trying to shoot a fly with a bazooka. of course it will work, as the control will act as a real browser window (actually the internet explorer browser), but its not really meant to be used in the way you need it.

the second option is to use something I just discovered while looking for more information about playing flash content inside a windows form. F-IN-BOX is a commercial solution that will also play content from a given website URL. (The link provided will direct you to the .NET code you have to use).