Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Play MP3 Files in VB6

457 views
Skip to first unread message

Rod Johnson

unread,
Mar 1, 2008, 6:07:55 PM3/1/08
to
Does anyone have the Code and Declarations necessary to play
MP3 Files in VB6? This must be done without the Windows Media
Player Console becoming visible. Much the same way that .wav files
are handled in VB6.

Any help greatly appreciated.

Thanks,

Rod Johnson
uni...@eircom.net

BeastFish

unread,
Mar 2, 2008, 2:48:26 AM3/2/08
to
MCI. Here's a website you can check out...

http://www.geocities.com/smigman.geo/mci/home.html

IIRC (haven't done it in years)... with MCI, you'd play mp3's the same way
as wav's...

http://www.geocities.com/smigman.geo/mci/wav.html

I'd also suggest going over to www.planetsourcecode.com and searching for
"mp3" or "mp3 player" (sans quotes) under VB.


"Rod Johnson" <uni...@eircom.net> wrote in message
news:cllyj.24720$j7.4...@news.indigo.ie...

Mike Williams

unread,
Mar 2, 2008, 2:58:21 AM3/2/08
to
On 1 Mar, 23:07, "Rod Johnson" <uni...@eircom.net> wrote:

> Does anyone have the Code and Declarations
> necessary to play MP3 Files in VB6? This
> must be done without the Windows Media
> Player Console becoming visible.

There are a number of different methods available. The MCISendString
API is probably the most commonly used method, but it can be a bit
"fiddly" until you get used to all its little idiosyncransies. An
alternative is to use the ActiveMovie Type Library, which is a nice
wrapper around this stuff and which can play all sorts of media files,
including wav and mp3, and it can even play video with sound in a VB6
PictureBox if you want. Playing and fully controlling video of course
requires a bit of a learning curve (although it is not too difficult a
task) but just playing an mp3 song is extremely easy. It is not a
control or an external component and so it does not require anything
extra to be bundled with your app. To try it out, start a new VB6
project and place a Command Button on the Form. Then use the Project /
References menu and scroll down and place a tick in the little box
against ActiveMovie control type library. Then paste in the following
very simple code and run the project and click the button (obviously
you will need to change the hard coded mp3 name in the example to the
path and name of an mp3 song on your own machine):

Private Sub Command1_Click()
Static player1 As Object
Set player1 = New FilgraphManager
player1.RenderFile "c:\temp\american pie.mp3"
player1.Run
End Sub

Mike


Mike Williams

unread,
Mar 2, 2008, 3:48:48 AM3/2/08
to
On 1 Mar, 23:07, "Rod Johnson" <uni...@eircom.net> wrote:

. . . in fact, if you like Kate Bush, as I do, and if you have a video
of her, you can try:

Private Sub Command1_Click()
Static player1 As Object
Set player1 = New FilgraphManager

player1.RenderFile "c:\kate bush.mpg"
player1.Run
End Sub

This plays the video in its own separate window, but it is much
simpler than playing it at any size you wish in a PictureBox on your
Form, which requires a bit more code (but which is still easily
"doable").

Mike


Rod Johnson

unread,
Mar 2, 2008, 4:21:43 AM3/2/08
to
I had initially thought that using MP3 Audio Files
in VB6 was much the same as that for the .wav and .mid
Files I have been using for some years now which only
require a Module Declaration and Procedures such as
Soundsub and Playsound. I was further misled by double-clicking
on an MP3 File within Windows Explorer and seeing an Audio Console
appear which played the File. It was this Audio Console that
I was referring to when specifying that I did not want
this visible when the MP3 Files were played.

I now find that I was completely off track altogether. One
respondent referred to the ability to make the Player
invisible when running it. After thinking about this, I
suspected that possibly a VB Control was involved. I found
the Microsoft Multimedia Control 6.0 (SP3) [MCI32.ocx]
in Project/Components. Once I had this Control on the Form,
I was then able to derive the necessary Code from the
Properties and the Pop UP Menus which appear when writing
the Code. All is now working OK. This issue is resolved.
Many thanks... Rod.


"Rod Johnson" <uni...@eircom.net> wrote in message
news:cllyj.24720$j7.4...@news.indigo.ie...

Mike Williams

unread,
Mar 2, 2008, 5:22:01 AM3/2/08
to
On 2 Mar, 09:21, "Rod Johnson" <uni...@eircom.net> wrote:

> One respondent referred to the ability to
> make the Player invisible when running it.
> After thinking about this, I suspected that
> possibly a VB Control was involved. I found
> the Microsoft Multimedia Control 6.0 (SP3)

> [MCI32.ocx] in Project/Components . . .

As you have discovered, and as we said in our various responses, there
are many different ways of playing media files from VB. Some methods
require very little VB code and others require more and some require
you to use a control that is not built into the VB6 runtime itself and
others do not, but in the end they all boil down to addressing the
same Windows media components but in different ways using different
wrappers (or no wrappers at all). Personally I do not use the
Multimedia Control because to do it properly you need to include the
appropriate ocx in your distribution package, which is something I
prefer to avoid. But each to his own. Others would disagree. One way
is as good as the next, as long as it works reliably.

Mike

0 new messages