tags:

views:

2137

answers:

4

I'd like to play mp3 files (b/c they compress smaller than .wav's) from a vb6 app but without needing any other player installed.

Any suggestions?

A: 

Not sure whether you would consider it as "being installed" since it comes with the OS, but you can control windows media player from vb6.

jkchong
WMP does always ship with the OS in Europe: see http://en.wikipedia.org/wiki/Windows_media_player#European_Commission_case
onedaywhen
+1  A: 

Use a DLL, for example FMOD to play the mp3 files.

schnaader
Additionally, Bass does the same thing, but with different interfaces which might be more usable: http://www.un4seen.com/
Frans Bouma
FMOD needs a separate MP3 license and has a separate commercial license.
Jasper Bekkers
A: 

Add reference to ActiveMovie control type library and use FilgraphManager.RenderFile. Take a look at VbAmp Player's docPlayer.pvLoadMediaFile for sample and check out the usage of IBasicAudio thoughout the source -- volume control, etc.

cheers,
</wqw>

wqw
+2  A: 

The easiest way to play an MP3 in VB6 is using the MCI in windowsmultimedia (winmm) functions. These are available in all versions of windows that can play MP3s in windows media player (by default in 2000, XP and I believe 98, needed to install Windows media player for NT4 and 95). Add the following to your header:

Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal _
    lpstrCommand As String, ByVal lpstrReturnString As String, _
    ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Then add the following in your subroutine:

CommandString = "open """ & FileName & """ type mpegvideo alias " & FileName
RetVal = mciSendString(CommandString, vbNullString, 0, 0)

The file type should mpegvideo not wavfile or sequencer, I guess because it uses the mpegvideo codec to play the file back. Legal questions relating to use of the MP3 codec and whether or not you are using windows to play it back or not is left up to your legal department if you plan to distribute your application.

Kris Erickson