OK i know this is an incredibly simple question but i want to start a .MPG by clicking a command button in my application but i can't get the SHELL command to do it, Should i be using a different command?
Printable View
OK i know this is an incredibly simple question but i want to start a .MPG by clicking a command button in my application but i can't get the SHELL command to do it, Should i be using a different command?
Yeah, my man. You should use the Windows API call ShellExecute.
Haven't worked with API at all yet so i have no idea how to go about it :(
Why not use Windows Media Player? Add it to your componets list and use the following commands to play/stop it.
Code:'To play a file
MediaPlayer1.filename = "C:\windows\desktop\combat.mpg"
MediaPlayer1.Play
'To stop playing
MediaPlayer.Stop
That works as long as i put Media Player in my application i just wanted to start the particular .mpg seperately, matter of fact i was going to unload the form as soon as i started the .mpg
Just pass the filename as the command line argument.
Code:Shell "C:\Program Files\Windows Media Player\wmplayer.exe C:\MyMpg.mpg", vbNormalFocus
Can always count on you Megatron, the next question would be ...Does it work the same for an .AVI?
ok i can open an .avi in Media Player the same way, but what if space aliens had deleted the users Media Player, is there anyway to start the file in whatever is available?
To open any file with it's default App, use the ShelExecute API.
Code:Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
ShellExecute hwnd, "open", "C:\MyAVI.avi", "", "", 1
End Sub
Thanx Megatron, I'd buy ya a house but Bill Gates presently has all my funds:(
But now supposing someone snuck into his house and replaced his PC with a Mac, what would happen?
With the splitting up of Microsoft, Gate's wealth will decrease significantly seeing how he's only allowed to own stock in one company.
Also, VB will not work on a Mac, however there are other sorts of BASIC for the Mac such as Applesoft Basic.
Don't think I'll worry about Mac, I was just supposin'...
So now another question, I'm using Media Player in my app., Is there any way i can package Media Player with my app. so if the user, for some ungodly reason, doesn't have it installed my program will still run from the CD?
For this project i wasn't planning on installing anything on the users HD, it's a demo that'll run off the CD, in other words i wasn't going to make a setup file
[Edited by PJB on 08-19-2000 at 10:09 PM]
Hey Megatron! Appreciate the help you've given so far. One question, If I want to allow my LAN users to click on a button & have the DEFAULT media player(which SHOULD be Windows Media Player-since we're Win98/NT <g>) launch & play a file that has been stored in a Network DB on a Server, can this code do that? Or is that even possible? Thanks for any help!