Click here to Skip to main content
15,909,091 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am new to VB.NET.
I need to run a media file in my project using VB.Net form application.
Is it possible to open a media file? If so could you please explain it.

Thanks in advance.

Vijay
Posted

Yes, it can be done for example through directx. You should locate some control for example picturebox on the form. This picturebox has a name PictureBox1. You should add Microsoft.DirectX.AudioVideoPlayback library to the project and then import it
Then you should write some code :
VB
Dim videoFile As New Video("Here the full path to the media file")
 videoFile.Owner = PictureBox1
videoFile.Play()


The supported file extentions depend on installed video codacks in your system.
 
Share this answer
 
Hi Eugene Popov,

Thanks for the answer.

However, I was planning not to use DirectX component and instead to use Windows media player.

I got below answer in net and find its working fine

-------------------------------------------------------------------------------------
Go to tools, add toolbox items, Com Components then click on Windows Media Player...this will add it to the toolbox and you can drag it to your form.
You should rename the control to something like Player for example then you can code it something like this:
view sourceprint?
1
Player.URL = "Your complete Path"
2
Player.Ctlcontrols.play()
You need to go to tools, add toolbox items, Com Components then click on Windows Media Player...this will add it to the toolbox and you can drag it to your form.
You should rename the control to something like Player for example then you can code it something like this:
view sourceprint?
1 Player.URL = "Your complete Path"
2 Player.Ctlcontrols.play()
------------------------------------------------------------------------------------

Thanks again,

Vijay
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900