Whether you are making a media player or if you simply would like to display audio or video inside your CSharp .Net application, Windows Media Player is a fast, reliable and easy to implement solution.
The steps given below will show you how to add the Windows Media Player control to your project and then, load and play a media file.
Step One - Adding the Windows Media Player Control
To use the Windows Media Player in your Window's Form control, you will need to add a reference to wmp.dll to your project.
First, click the 'Project' menu and select the 'Add Reference...' button. Next, switch to the 'COM' tab and search for the entry entitled, 'Windows Media Player', double click this entry.
Windows Media Player is now referenced, but it still needs to be added to the controls toolbox. In the toolbox, right click a blank area and select the 'Choose Items' button. Go to the 'COM Components' tab, find and check 'Windows Media Player' and press OK.
The Windows Media Player control will now be available in the toolbox. Click and drag this control on to your desired form and set the size and properties accordingly.
Step Two - Loading Media Files
With the Windows Media Player control added to the form and ready for use, go into your form's code view. Go to the function where you would like to load a media file and use this source code,
axWindowsMediaPlayer1.URL = @"C:\Mediafile.avi";
axWindowsMediaPlayer1.Ctlcontrols.play();
You will need to replace the 'axWindowsMediaPlayer1' with the name of your Windows Media Player control. Also, replace the 'C:\Mediafile.avi' with path to the media file. The code will automatically load the given media file and start playing it.
Conclusion
There are many option and function included in the Windows Media Player control that will allow you customize it according to your needs and desires. For more information on these abilities check out Microsoft's MSDN entry for the Windows Media Player Control located here,
http://msdn.microsoft.com/en-us/library/dd563946%28v=VS.85%29.aspx
Published by James Cloud
I like to program and do basically anything that has to do with technology and computers. View profile
- CSharp .Net Tutorial: Move a Borderless FormLearn how to give the user the ability to move a borderless form in your CSharp .Net Applications.
- Csharp .Net Tutorial: Catching ErrorsLearn how personally deal with errors in your CSharp .Net projects.
- CSharp .Net Tutorial: Read / Write RegistryLearn how to manipulate the system registry using CSharp .Net.
- CSharp .Net Tutorial: Draw Strings on a FromLearn how to draw a string anywhere on your form in CSharp .Net.
- CSharp .Net Tutorial: How to Skin Your FormsA free way to skin your Windows Form application in CSharp .Net.
- Make Windows Media Player a Universal Player Using Codecs
- CSharp .Net Tutorial: Picture Box Load Icon
- Csharp.Net Tutorial: Playing Audio with DirectX
- CSharp .Net Tutorial: Loading Textures in Truevision 3D
- CSharp .Net Tutorial: Sending Email
- CSharp .Net Tutorial: Directory Manipulation
- CSharp .Net Tutorial: Reading and Writing INI



