It sounds to me like the problem is not so much how to use the DirectShow library (the `DirectShow.Net Forum is specifically designed for that), but rather how to use an embedded resource.
I ran into something similar a few years back on a contract job where an employer was worried that some customer might steal his proprietary information. My information was in hundreds of PDF documents, but the idea works the same for video files.
Here's how I tackled the problem:
First, place the video file in your list of resources: I use Visual Studio
, so I go to the Project
's Properties, click the Resources tab, select the Files option, then select Add Resource
> Add Existing File...
Add the following two namespaces
to the code file you will be using:
using System.IO;
using System.Diagnostics;
- Finally, where you want to play your video file, just do something similar to the following:
Process player = null;
string tempFile = "~clip000.dat";
try {
File.WriteAllBytes(tempFile, Properties.Resources.MyMovie_AVI);
player = Process.Start(tempFile);
player.WaitForExit();
} finally {
File.Delete(tempFile);
}
Most likely, you will not be calling the Process.Start
method, but rather the appropriate DirectShow
method. The idea is still the same: Extract your resources as a byte
array, write them to a new, temporary file, use the file, then delete that file whenever you are done.
Be sure to put the Delete
statement in the finally
block so that if any errors occur or your user closes the program while the file is still playing, your application still cleans up the old file.
EDIT:
I think this might be a viable way of doing this:
using (MemoryStream ms = new MemoryStream(Properties.Resources.MyMovie_AVI)) {
// Now you have to find a way in `DirectShow` to use a Stream
}