PDA

Click to See Complete Forum and Search --> : Palying a Wav in the Background


Dec 30th, 1999, 09:36 AM
I want to play Wav files in the background on my slide show project. These are large wav files, approx. 30MB each. The user selects them from the menu bar, thne the Wav file starts, plays, and stops. How do you do this?

this is what I have:

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_NODEFAULT = &H2

Private Sub mnutruly_Click()
Call sndPlaySound("D:\Pictures Do Not Delete\truly.wav", SND_NODEFAULT)
End Sub

The problem is this loads up then plays but my slide show doesn't continue, why?

KnightM
Dec 30th, 1999, 09:44 AM
I have found that it is much easier just to make it spawn another program that you have made. For example, when the user selects the wav that they wish to play, have it "shell" a program that calls that wav to play. Then you can just use form.hide in the form.load of the wav program. I hope you understand what I mean :) This way, the wav will play while other things are going on.

-KnightM

Bob Baddeley
Dec 30th, 1999, 10:00 AM
I disagree. I think your problem can be fixed with one number. when you set SND_NODEFAULT as &H2, try &H1 instead. I believe that will fix it. At least it did on my program. If it works or doesn't, post again so I know. Also, you might want to change it to a midi or an mp3, so it'll be smaller.

good luck,

bob

Dec 31st, 1999, 12:47 AM
Maybe I'm doing something wrong but I'm not getting any sound to play? Also if I burn this on a CD and point the sound file to the CD will that speed up the process of playing the music, and cause less lag time in my slides? Please check my code above, and see what you think. I have the top section in a General Declaration, should I have a module or anything else?

Bob Baddeley
Dec 31st, 1999, 03:57 AM
In the module, put:


Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long


in the form put:


Call sndPlaySound("Name of your file", &H1)


If it doesn't work, check the mute button. or your volume control. Otherwise, I don't know what to tell you. This works just fine on my computer.

bob

Frans C
Dec 31st, 1999, 09:18 AM
Declare the following constants:
Public Const SND_ASYNC = &H1
Public Const SND_NODEFAULT = &H2
and call the function like this:
Call sndPlaySound("D:\Pictures Do Not Delete\truly.wav", SND_ASYNC Or SND_NODEFAULT )
That should do the trick.

Juan Carlos Rey
Jan 1st, 2000, 05:09 AM
Why are your Wav files that large?
Are those uncompressed?
I use MP3 Producer to compress wav files. It let you select the level of compression, and your compressed file can be as much as one tenth of the original size, but IT KEEPS .WAV FORMAT, so any Wav player can cope with it, no need for special MP3 players.

wengang
Apr 10th, 2000, 06:17 AM
Bob,
I tried that on a wav file and got it. Any such code for a midi file?

I am using this format:
Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, _
ByVal lpstrReturnString As String, ByVal uReturnLength As Long, _
ByVal hwndCallback As Long) As Long

I would like to put the midi in the background but it currently plays in the foreground, stopping the program.

Thanks.

wengang
Apr 10th, 2000, 06:17 AM
Bob,
I tried that on a wav file and got it. Any such code for a midi file?

I am using this format:
Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, _
ByVal lpstrReturnString As String, ByVal uReturnLength As Long, _
ByVal hwndCallback As Long) As Long

I would like to put the midi in the background but it currently plays in the foreground, stopping the program.

Thanks.

wengang
Apr 10th, 2000, 06:18 AM
Bob,
I tried that on a wav file and got it. Any such code for a midi file?

I am using this format:
Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, _
ByVal lpstrReturnString As String, ByVal uReturnLength As Long, _
ByVal hwndCallback As Long) As Long

I would like to put the midi in the background but it currently plays in the foreground, stopping the program.

Thanks.