views:

5775

answers:

5

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.

+9  A: 

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).

Sven
A: 

I upvoted Sven's answer but just a little note: using the WebBrowser component is quite manageable, and in fact, it's intended for exactly this kind of use (embedding in application UIs). You can point the browser control at a URL, sure, but you can also exactly specify the content it contains, respond to events, and so forth. There's even an embedded resource protocol/scheme (res://) which you can use to reference embedded resources.

But obviously if the Flash component itself is clean, that's a better way to go :)

James D
A: 

As CodingTheWheel has pointed out, my choice of wording is indeed a bit off.

I believe that you should use the webbrowser component only as a last resort for your problem, but it will manage just fine if you should decide to use it.

Sven
+3  A: 

Sven, you reached the same conclusion as I did: I found the Shockwave Flash Object, all be it from a slightly different route, but was stumped on how to load the files from somewhere other than file on disk/URL. The F-IN-BOX, although just a wrapper of the Shockwave Flash Object seems to provide much more functionality, which may just help me!

Shooting flys with bazookas may be fun, but an embeded web brower is not the path that I am looking for. :)

For those that are interested here is a link (that I have just found) on embeding flash in C# Winforms applicaitons: Embedding and Communicating with the Macromedia Flash Player in C# Windows Applications

FryHard
A: 

+1 for using the WebBrowser control. It's built into the framework (2.0 or later), so you don't need to worry about A) deploying anything new/separate as a part of your application and B) doing any sort of COM/Interop stuff from within your managed code.

Our application uses the control to display training screencasts directly inside the application. Provided the user has an internet connection, we're good to go -- though the WebBrowser control can just as easily open from a local disk or dynamic content you're generating.

Jeff Donnici