how to play mp3 direct from database

sean1

New member
Local time
Today, 06:03
Joined
Sep 13, 2009
Messages
7
I'm new to Access but have made a database of my music collection. Is it possible to get the selected mp3 file to play on the click of a button directly from a form? please reply

thanks
 
Code:
Sub OpenAFileUsingItsRegisteredWindowsProgram(filespec As String)
   CreateObject("Shell.Application").ShellExecute filespec
End Sub
 
wer do i enter the code
 
You have a few options really about where to put it. Maybe the button click event handler on the form in question? Maybe a macro.
But you need to pass in the filename too. Do you know how to get that info off your form? Button click code would look like...
Code:
private sub yourButton_Click()
  CreateObject("Shell.Application").ShellExecute me.somefilename
End Sub
where 'me.somefilename' references a control containing the name of the file you want to open.
 
If you drop a button on a form in design view, does a wizard pop up to help you? If so, go along with the wizard. Then go look at the code the wizard wrote. Delete everything except the first and last lines. You'll have something like...
Code:
Private Sub YourButton_Click()
End Sub
Now paste in the one line of code from this thread.
Last thing you need is to figure out the name of the control that displays your filename. Open your form in design view, look around. It's there. Type it in. Done.
Cheers,
 
You can actually imbed a Windows Media Player object into Access, and point that control to an MP3 file. I did that as a April Fool's joke at work once. I made it hidden, and when they opened the form, Johnny Cash's "Ring of Fire" started playing.
 
You can actually imbed a Windows Media Player object into Access, and point that control to an MP3 file.

So does this mean the Media Player is actually embeded in the database and can play the sound on a computer that does not have Media player installed?

Also how do you "point the control to [a file]" ?
 
If the computer did not have Windows Media player, it probably wouldn't work. Unless the little engine to play it was included with Access, but every every PC comes with WMP, and Macs can't use Access, so it shouldn't be a problem.

In the design view of your access form access form, click on your little icon that looks like a wrench and a hammer "more controls", then scroll down to Windows Media Player. You'll see it drop right down on the page. Really easy.

You can then right click on that control go to properties and see all the options you have to play with.

On the "Other" tab go to custom and click on the button that appears to the right. Another property page, specific to WMP will pop up. That's where you point it to a specific file.
 
Thanks arichins.

I'm using Access 2007. The wrench and hammer icon has a Tool Tip saying "Set Control Defaults". However I found the WMP under ActiveX controls and inserted it. Otherwise all good.

I asked about embedding a program that was not otherwise on the computer because I wondered if a database could be distributed with an executable file stored inside it rather than as a separate file. Of course it would have to be a program that did not need to be installed to run.

If that was possible could a file also stored inside the database be handed to the embedded executable and run?

Would be a tidy solution with all the functionality inside the one database file and no need for the executable to be separately managed.
 
If your looking for a solution that will work on any pc, then the embedded wmp is probably the way to go. It will work on any pc that has your version and service pack of access.
 

Users who are viewing this thread

Back
Top Bottom