1,105,375 Community Members

How to play Video?

Member Avatar
VibhorG
Junior Poster in Training
71 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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............

Member Avatar
sknake
Senior Poster
3,957 posts since Feb 2009
Reputation Points: 1,620 [?]
Q&As Helped to Solve: 747 [?]
Skill Endorsements: 25 [?]
Featured
 
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.

Member Avatar
__avd
Posting Genius (adatapost)
6,703 posts since Oct 2008
Reputation Points: 1,811 [?]
Q&As Helped to Solve: 1,272 [?]
Skill Endorsements: 61 [?]
Moderator
 
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.

Member Avatar
jbennet
Moderator
17,127 posts since Apr 2005
Reputation Points: 1,618 [?]
Q&As Helped to Solve: 736 [?]
Skill Endorsements: 38 [?]
Team Colleague
Featured
 
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

Member Avatar
VibhorG
Junior Poster in Training
71 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
-1
 

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

Member Avatar
VibhorG
Junior Poster in Training
71 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
-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.................?

Member Avatar
VibhorG
Junior Poster in Training
71 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
-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..........?

Member Avatar
VibhorG
Junior Poster in Training
71 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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..........?

Member Avatar
VibhorG
Junior Poster in Training
71 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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........?

Member Avatar
__avd
Posting Genius (adatapost)
6,703 posts since Oct 2008
Reputation Points: 1,811 [?]
Q&As Helped to Solve: 1,272 [?]
Skill Endorsements: 61 [?]
Moderator
 
0
 

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

Member Avatar
avirag
Posting Whiz
312 posts since Jun 2009
Reputation Points: 10 [?]
Q&As Helped to Solve: 36 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi all,
Can anyone tell me how can we play the video(.wmv) in C# window application .................?

Take a look at this also.
http://www.codeproject.com/KB/directx/directshowmediaplayer.aspx

Member Avatar
sknake
Senior Poster
3,957 posts since Feb 2009
Reputation Points: 1,620 [?]
Q&As Helped to Solve: 747 [?]
Skill Endorsements: 25 [?]
Featured
 
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

Member Avatar
VibhorG
Junior Poster in Training
71 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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..

Member Avatar
sknake
Senior Poster
3,957 posts since Feb 2009
Reputation Points: 1,620 [?]
Q&As Helped to Solve: 747 [?]
Skill Endorsements: 25 [?]
Featured
 
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.

Member Avatar
VibhorG
Junior Poster in Training
71 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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.....

Member Avatar
sknake
Senior Poster
3,957 posts since Feb 2009
Reputation Points: 1,620 [?]
Q&As Helped to Solve: 747 [?]
Skill Endorsements: 25 [?]
Featured
 
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?

Member Avatar
VibhorG
Junior Poster in Training
71 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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, avirag and 1 other
Member Avatar
Diamonddrake
Master Poster
721 posts since Mar 2008
Reputation Points: 396 [?]
Q&As Helped to Solve: 92 [?]
Skill Endorsements: 8 [?]
 
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