1.11M Members

How to play Video?

 
0
 

Hi all,
Can anyone tell me how can we play the video(.wmv) in C# window application .................?
Let i have some links on window form, As the user click on that link, related video should start playing.....
And i am using VS2008.......
Kindly help me regarding this............

 
1
 

You can embed windows media player in your application which can play videos from your harddrive or stream them from a URL.

Add a reference to "Windows Media Player" aka Interop.WMPLib.dll, and then navigate to the controls in that DLL (using the "customize toolbox" menu option). You will see a media player control. Drop it on your form and away you go.

 
0
 

Good suggestion from scott. Here is a good example to play a video using DirectX - http://www.codeproject.com/KB/graphics/zMoviePlayer.aspx. You may use MCI - Media Control Interface API to play video.

 
1
 

. Here is a good example to play a video using DirectX - .

You can also play video in a 3d space using the XNA framework if you want to do some fanciness

 
-1
 

Thank you all for your replies..............

 
-1
 

@sknake
Well sknake i want to to inbuilt video in my application, and want to play videos from there, like as user click on link, related video should start on form.
Can i do this thing as well with add to reference of Window Media Player in my application.................?

 
-1
 

You can also play video in a 3d space using the XNA framework if you want to do some fanciness

jbennet can you please tell me how can i use XNA framework in my application, i never used this..........
Can you explain me something more about this..........?

 
0
 

Good suggestion from scott. Here is a good example to play a video using DirectX - http://www.codeproject.com/KB/graphics/zMoviePlayer.aspx. You may use MCI - Media Control Interface API to play video.

One thing i want to ask you, if i am using DirectX to develop my application, So is it necessary that DirectX should also be installed on User end..........?

 
0
 

You can embed windows media player in your application which can play videos from your harddrive or stream them from a URL.

Add a reference to "Windows Media Player" aka Interop.WMPLib.dll, and then navigate to the controls in that DLL (using the "customize toolbox" menu option). You will see a media player control. Drop it on your form and away you go.

Well sknake i have done whatever you mentioned here,
BUt now tell me how can i run the video inside this........?

 
0
 

Vibhorg -- Adatapost provided the article you should read regarding embedding the media player. Take a look and see if that solution meets your needs.

Well sknake i have done whatever you mentioned here,
BUt now tell me how can i run the video inside this........?

Take a look at this article - http://msdn.microsoft.com/en-us/library/dd562851(VS.85).aspx

 
0
 

Vibhorg -- Adatapost provided the article you should read regarding embedding the media player. Take a look and see if that solution meets your needs.

Yes, but i just have one query regarding this, that the code behind the play button is:

axWindowsMediaPlayer1.URL = @"C:\Documents and Settings\All Users\Documents\My Music\Sample Music\Videofile.wmv";

In this it is load the video from our system(hard drive of user), but in my application i have inbuilt some videos with it, and i want that when user click on play button so video load from that location(In to my application).
Kindly help me in that Sknake..

 
0
 

This depends how you have the videos inbuilt. If they're compiled in as an embedded resource you could do something like:

private void button3_Click(object sender, EventArgs e)
    {
      string tmpFile = System.IO.Path.GetTempFileName();
      File.WriteAllBytes(tmpFile, Properties.Resources.File_MOV);
      //mediaPlayer.URL = tmpFile;
      //mediaPlayer.Play();
    }

Be sure to clean up your temp files when the application closes.

 
0
 

This depends how you have the videos inbuilt. If they're compiled in as an embedded resource you could do something like:

private void button3_Click(object sender, EventArgs e)
    {
      string tmpFile = System.IO.Path.GetTempFileName();
      File.WriteAllBytes(tmpFile, Properties.Resources.File_MOV);
      //mediaPlayer.URL = tmpFile;
      //mediaPlayer.Play();
    }

Be sure to clean up your temp files when the application closes.

No Sknake this is not what i want,
Let i have a folder(name video) in my application, and i m put(copy) some videos in that folder, now i want to play these videos into my form.
How can i do this ..............
I thing now my problem is clear to you.....

 
0
 

Just set the path to C:\Program Files\Wherever you installer your application\Videos\video1.mpg and play the video. I don't understand why this is a problem?

 
0
 

Just set the path to C:\Program Files\Wherever you installer your application\Videos\video1.mpg and play the video. I don't understand why this is a problem?

Okey thank you..........

Question Answered as of 4 Years Ago by sknake, __avd, jbennet and 1 other
 
0
 

Its a far back reference, but using DirectX is a very good practice. and all windows computers XP and up have DirectX installed. It's installed with windows and comes as an automatic update as well. The managed directX libraries have very easy to use audio and video objects that is as simple as passing it a filepath, giing it a parent control to play on, and calling play.

This is just for future reference. Glad you already have this solved.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article