aweiss -<br><br>The answer to this is the same as opening a HTML document, or opening a .doc file, etc. You use the ShellExecute API, which uses the extension of the file you pass (.mp3, in your case) to open the default viewer for that file type.<br><br>So, for a MP3 file called GroovySong.mp3, if the user has Sonique as their default MP3 player, it'll start Sonique and pass your GroovySong.mp3 along for it to play. If the user had RealPlayer as their default MP3 player, it would use that program to play the song.<br><br><i>Here's the declare statement:</i><br><FONT FACE=monospace> 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<br> Private Const SW_SHOWNORMAL = 1</font><br><br><i>And here's the call to it:</i><br><FONT FACE=monospace> Call ShellExecute(Me.hwnd, "open", MP3FilePath, vbNull, vbNull, SW_SHOWNORMAL)</font><br><br>Chip H.<br><br><br>
So basicaly if Windows has an Mp3 Codec installed(like If you have the updated version of Media player) then media player control or API will play any codec supported. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href=
</a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
It's more than just the codec -- ShellExecute looks in the registry at the default value for the .mp3 extension (HKEY_CLASSES_ROOT\.mp3) for the program to launch. On my machine it's "RealPlayer.MP3.6", which corresponds to the registry key:<br><br> HKEY_CLASSES_ROOT\RealPlayer.MP3.6\shell\open\command<br><br>which the default value contains<br><br> "C:\Program Files\Real\RealPlayer\RealPlay.exe" /m audio/mpeg %1<br><br>If the codec isn't found, the program itself will raise an error after it gets launched (or just die in silence, depending on how it's author wrote it)<br><br>Chip H.<br><br><br>
Of course I think he'd rather have his own player try to play it thru the codec, rather than openning the default player. which is why I recomended the Media player API.<br>(and if his own cant, have it prompt the user to get codec, or whichever helps) <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href=
</a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
Ahhh, I didn't catch that. I naturally assumed he just wanted some sound to come out of the speakers, and didn't care how it got there, which is why I suggested that he just use whatever the default MP3 player is.<br><br>If he's trying to write a MP3 player in Visual Basic, wow! Media Player API would definately be the place to start.<br><br>I saw in the O'Reilly book catalog that they have a title out now that is all about MP3 (has some kind of crab or something on the cover), but I think it doesn't delve into the algorithms.<br><br>Chip H.<br>
Well if he wanted to write his own decoding MP3 player(like winamp or sonique, that decodes it themselves and not rely on Microsoft codecs) I definitly wouldnt think it would be very effective in Visual Basic, sounds more like something that should be done in C++, but oh well, hope either of our post were helpful for the language he is in. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href=
</a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
You can skip all this stuff and add the activeX component included with Pro and Enterprise Editions called active movie player. Set it to be visible=false in your form.load, and set its filename, Ex:
Activemovie1.filename = "C:\mysong.mp3"
Once the file is open and ready for play, the Activemovie player will trigger an Open_Complete event. You can use this to tell if the file is good to run. If you attempt to play a file, it will either not play or the previously loaded file will run instead. You play a file by executing:
Activemovie1.run
Stop it with: Activemovie.stop
You can tell where you're at using:
X = Activemovie1.currentposition
X is in tenths of seconds. You'll find you can do a lot with this cool control including playing more than one file at a time (mixing). You can set its playback volume and speed.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.