Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Play wav files 2

Status
Not open for further replies.

suruppak

Programmer
Mar 12, 2003
17
US
In my database I have created a table "tblMusic", in which I have a .wav file stored. I want this file to be played the entire time the application is being used, running on an endless loop.
So far, the only way I can get it to play is I created a form frmMusic, and made it a subform on the frmMain, with a button that you can double-click to hear the music. When you exit the form, the music stops. I don't know how to automate the playing of the music, or how to make it form independant.
Thanks for any help anyone may give,
Jeremy
 
This isn't exactly what you asked for, but will play a .wav file located in the same folder as your DB.

Place this in the On Load Event of a Form that Loads at Startup like Switchboard or a Menu Form, one that is always Open:

Dim strWav As String, strPath As String, retval
strPath = "YourFileName.wav" ' change this to your .wav file
strWav = CurrentProject.Path & "\" & strPath
retval = PlaySound(strWav, 0, SND_ASYNC Or SND_NODEFAULT Or SND_LOOP)

Place this in the On UnLoad Event of the same Form:

Dim retval
retval = PlaySound("", 0, SND_PURGE Or SND_NODEFAULT)

Create a New Module, paste this into the Declarations Section:

Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" _
(ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Public Const SND_SYNC = &H0
Public Const SND_ASYNC = &H1
Public Const SND_NODEFAULT = &H2
Public Const SND_LOOP = &H8
Public Const SND_NOSTOP = &H10
Public Const SND_PURGE = &H40

Save the Module as anything you like.

Each time the Form Loads your selected .wav File will Play until your DB is closed.

Good Luck

Bill
 
That's not exactly what I was looking for, but it was helpful and educational. Thanks Bill!
 
Hi,
I think that you should create an unbound form and set up the ON Timer Event to play the looped music. Keep the form open and hide it, and this should ensure the result you require,

Regards,

Trystan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top