Playing Music

  • Thread starter Thread starter Bruce Rodtnick
  • Start date Start date
B

Bruce Rodtnick

I have a database that has my music information in it. If I have an mp3
of that piece of music a button appears so I can play the music. BUT, I
can't get it to play. I want an application to open, in this case
Winamp, which is my default music player, and play my mp3. I've been
trying to use a shell for it to just call the mp3, but I can't get it to
work. Here is my code:

Dim strPlaySong As String
strPlaySong = "mp3\" & Me!Name & ".mp3"
Shell = strPlaySong

I've also tried:
Call Shell(strPlaySong) ', vbNormalFocus

I don't want to use Dev Ashish's or Allen Brown's sound modules because
I want to be able to stop the mp3 (it can be 6 minutes long).

Any ideas?

Bruce Rodtnick
 
Bruce,

I think you should be including the full path to the mp3 file, e.g.
strPlaySong = "C:\MyFolder\mp3\" & Me!Name & ".mp3"

- Steve Schapel, Microsoft Access MVP
 
I don't believe that my problem. I have the mp3 in a subdirectory in the
same directory that the database is in. So mp3\ refers to that
subdirectory. I do this because I'm using this database in two places, one
in the office where the database is on a network drive and at home where it
is not.

When I use the Shell = strPlaySong I get the error:

Compile Error:
Function call on left-handside of assignment must return Varient or Object

When I use Call Shell(strPlaySong) I get:

Run-time error 5
Invalid proceedure call or argument

B
 
Bruce,

.. I have the mp3 in a subdirectory in the
same directory that the database is in. So mp3\ refers to that
subdirectory..

I am not sure, but I have never seen this method used before, and as
far as I know it is not correct. I think the full path must be
specified. In fact, now that you mention it, as far as I know you
need to specify the full path of the Winamp programme as well.

- Steve Schapel, Microsoft Access MVP
 
Just because the active database is in a particular directory doesn't mean
that directori is the current directory.

Check what CurDir returns: if it's not the same as where the database is
located, you either need to use the full path as Steve suggests or (not
nearly as good a solution) use ChDir to change the current directory.
 
I don't agree that I need the whole path, but I put it in my code but
still got the same error messages.

In explorer, when I double-click on an mp3 file, it brings Winamp up and
plays the clip. That's essencially what I want to do. I want my code
to call the file song.mp3 and play it, hopefully in Winamp since it is
the default mp3 player on my computer. Winamp does not support
(apparently) commandline input (c:\winamp\winamp.exe play.mp3.

Does my code do what I want it to do, or is ther a better way?

Bruce
 
Bruce,

Sorry, I was not referring to what you may or may not need, or what
you may or may not agree with. I was talking about the required
syntax for the Shell command. I believe it should be:
"C:\winamp\winamp.exe C:\PathToFile\Song.mp3"

Another option would be to use a Hyperlink data type for the field
where you store the mp3 file names.

- Steve Schapel, Microsoft Access MVP
 
Back
Top