Hi,
I'm using the code (roughly) from http://www.dotnetmonst er.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
The picturebox is generated on the fly using an xml file to define where it is like this
The problem is that nothing is showing up in the picturebox. Am I doing something in the videoplayer class incorrectly or am I trying to play the video before it's time.
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
I'm using the code (roughly) from http://www.dotnetmonst er.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
Code:
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); } }
Code:
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