开发者

How can I load an SWF from a C# EmbeddedResource without first writing to file?

I'm using the flash 10 activex control to load a flash movie into my WinForm. Unfortunately, it only takes a path. What I'm trying to do is load the swf from a stream I can get from an EmbeddedResource so I can embed the swf int开发者_如何学Pythono my exe such that A) I don't have to worry about paths and B) I don't have my swf quite so exposed - simpler for both usage and deployment.

I know of using f-in-box but I'd like to not add yet another dependency to my project. Is there a way to load the swf into the underlying activex control without having to use a path?

I'm using C# and .Net 3.5sp1.


Is that path always a file path? Or can it be a URL? It should be pretty simple to set up a temp localhost web-server using HttpListener (or similar), that streams back the file in response to an http request.

Another possibility would be named pipes; I wonder if you can convince the control to open a named pipe as though it were a file? (they have a logical file path, after all). I've barely touched these, though - so I can't say 100% whether it would work.


I don't know if flash 10 supports the res protocol to load web content from resource. But I think the web browser control in Windows Forms and WPF support it.

To create a native resource you need an editor of native resource. Visual C++ has one. You can use RC.exe in Windows SDK to compile it to res files before linking in your C# program.

Update: Looks like the flash plugin for IE does not support the res protocol. embed the .swf file in a resource file and have it load using the movie parameter won't work. Try embed the Flash file in a web archive file (.mht) and add the .mht file to your resource.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜