Thursday, 23 May 2013

Tutorial: Play Audio and Video Files on VB.NET Using Media Player

I will teach you how to play audio and video files on VB.NET using Windows Media Player in 5 easy steps.

Step 1: Add the Windows Media Player component to the project.
Right-click Toolbox >> Choose Items >> COM Components tab >> Find and Select 'Windows Media Player' >> Ok

You ca now see the Windows Media Player object in the toolbox.


















Step 2: Add the Windows Media Player object on the form and expand it.

Step 3: Add an OpenFileDialog object.

Step 4: Add a MenuStrip to the form. Then add a File Menu. (You can use a button, click event of the wmp, menustrip or everything you want to do this.) Access the Click Event of the File Menu by double clicking it and add the following codes below:
OpenFileDialog1.ShowDialog()
AxWindowsMediaPlayer1.URL = OpenFileDialog1.FileName
 Step 5: Run the project by clicking F5. Click 'File' and open the video or audio you want to play!


















This is just a simple way of playing audio and video files using wmp. You can customize the OpenFileDialog and add filters or initial directory to make your program more usable. You can refer to this site to learn more! http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx

If this post helped you please take few seconds to share it! :)

No comments:

Post a Comment