473,395 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Redirecting a video to a picturebox using mciSendString

19
Hi,

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
  1.     public class video
  2.     {
  3.         [DllImport("winmm.dll")]
  4.         private static extern long mciSendString(string command, StringBuilder returned, int len, IntPtr callback);
  5.  
  6.         public void videoplayer(string filename, System.Windows.Forms.PictureBox pb)
  7.         {
  8.             string command = "";
  9.  
  10.             command = "open \"" + filename + "\" alias VideoFile wait";
  11.             mciSendString(command, null, 0, IntPtr.Zero);
  12.  
  13.             command = "window VideoFile handle " + pb.Handle.ToString();
  14.             mciSendString(command, null, 0, IntPtr.Zero);
  15.  
  16.             command = "put VideoFile destination at 0 0 " + pb.Width.ToString() + " " + pb.Height.ToString() + " wait";
  17.             mciSendString(command, null, 0, IntPtr.Zero);
  18.  
  19.             command = "play VideoFile";
  20.             mciSendString(command, null, 0, IntPtr.Zero);
  21.         }
  22.     }
  23.  
The picturebox is generated on the fly using an xml file to define where it is like this

Expand|Select|Wrap|Line Numbers
  1. if (fort.ElementType == "System.Windows.Forms.PictureBox" && fort.WithExternal == true &&
  2.                             fort.ExternalFile != "")
  3.                         {
  4.                             PictureBox b = new PictureBox();
  5.                             b.Location = new Point(fort.X, fort.Y);
  6.                             b.Name = fort.ElementName;
  7.                             b.Height = fort.Height;
  8.                             b.Width = fort.Width;
  9.                             b.SizeMode = PictureBoxSizeMode.StretchImage;
  10.                             if (fort.HasVideo == false)
  11.                             {
  12.                                 try
  13.                                 {
  14.                                     b.Image = Image.FromFile(place + fort.ExternalFile);
  15.                                 }
  16.                                 catch (System.NotSupportedException)
  17.                                 {
  18.                                     err.throwFileNotFound(place + fort.ExternalFile);
  19.                                 }
  20.                             }
  21.                             else
  22.                             {
  23.                                 video v = new video();
  24.                                 v.videoplayer(place + fort.ExternalFile, b);
  25.                             }
  26.                             b.TabIndex = fort.TabIndex;
  27.                             form1.Controls.Add(b);
  28.                         }
  29.  
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
Jul 28 '10 #1
0 1788

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mohamed Afifi | last post by:
Dear All how can i make video conferance using asp
4
by: jaffar | last post by:
hi, i am developing a windows application, in my application i have to stor video files into database and play those video files from database , how to da this application, send me replay as...
2
by: BigC | last post by:
I am using the following line of code to save a voice file (.wav) to disk and it works fine when the filename contains no spaces. However the file doesn't get saved when its name contains a space....
0
by: Muhammad Ammad Saleem | last post by:
Hi, I just want to extract the close captions from Video Clips using C# or the .NET Framework. I want to extract this information so that people can search for Video clips of there desire...
0
by: kofi | last post by:
hi everyone.. i am developing a media player using mcisendstring function call... i have encountered few problems so far.. 1...after setting the screen to fullscreen...the player pauses a video...
1
by: romcab | last post by:
Hi guys, Just want to ask your idea on how to do video streaming using C#. I want to create an application that can play video file. Is there an existing classes that I can reuse? Hope you can...
2
Nert
by: Nert | last post by:
Hello there., i have this problem converting an flv video format to 3gp format using ffmpeg so that i can put the video on my cellphone. Well actually i have successfully converted the video to...
13
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
This is a follow-up to my post "Silverlight video doesn't work when file is streamed from handler in ASP.net" at...
0
by: nodoid | last post by:
Hi, I'm using winmm.dll to display video. Currently it opens the video in it's own window. Is there any way that I can direct it into (say) a PictureBox in an already existent window (or something...
33
sword117
by: sword117 | last post by:
Im trying to create a video background using frames from a video, and using a timer to run the frames 30FPS , can someone help me out? its for a school project. im here so far, i can make this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.