I'm using the code (roughly) from http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-csharp/92578/Playing-an-avi-file-in-a-C-app to send a video to a picturebox (in this case, it's an mpeg file).
My code looks like this
Expand|Select|Wrap|Line Numbers
- public class video
- {
- [DllImport("winmm.dll")]
- private static extern long mciSendString(string command, StringBuilder returned, int len, IntPtr callback);
- public void videoplayer(string filename, System.Windows.Forms.PictureBox pb)
- {
- string command = "";
- command = "open \"" + filename + "\" alias VideoFile wait";
- mciSendString(command, null, 0, IntPtr.Zero);
- command = "window VideoFile handle " + pb.Handle.ToString();
- mciSendString(command, null, 0, IntPtr.Zero);
- command = "put VideoFile destination at 0 0 " + pb.Width.ToString() + " " + pb.Height.ToString() + " wait";
- mciSendString(command, null, 0, IntPtr.Zero);
- command = "play VideoFile";
- mciSendString(command, null, 0, IntPtr.Zero);
- }
- }
Expand|Select|Wrap|Line Numbers
- if (fort.ElementType == "System.Windows.Forms.PictureBox" && fort.WithExternal == true &&
- fort.ExternalFile != "")
- {
- PictureBox b = new PictureBox();
- b.Location = new Point(fort.X, fort.Y);
- b.Name = fort.ElementName;
- b.Height = fort.Height;
- b.Width = fort.Width;
- b.SizeMode = PictureBoxSizeMode.StretchImage;
- if (fort.HasVideo == false)
- {
- try
- {
- b.Image = Image.FromFile(place + fort.ExternalFile);
- }
- catch (System.NotSupportedException)
- {
- err.throwFileNotFound(place + fort.ExternalFile);
- }
- }
- else
- {
- video v = new video();
- v.videoplayer(place + fort.ExternalFile, b);
- }
- b.TabIndex = fort.TabIndex;
- form1.Controls.Add(b);
- }
I have tried putting the call to play the video after the control has been added, but to no avail - I get nothing.
Any advice would be appreciated
TTFN
Paul