Results 1 to 10 of 10

Thread: Palying a Wav in the Background

  1. #1
    Guest

    Post

    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?



  2. #2
    New Member
    Join Date
    Aug 1999
    Posts
    13

    Post

    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

  3. #3
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305

    Post

    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

  4. #4
    Guest

    Post

    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?

  5. #5
    Hyperactive Member
    Join Date
    Sep 1999
    Posts
    305

    Post

    In the module, put:

    Code:
    Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    in the form put:

    Code:
    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

  6. #6
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Post

    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.

  7. #7
    Hyperactive Member Juan Carlos Rey's Avatar
    Join Date
    Aug 1999
    Location
    Mendoza, Argentina
    Posts
    301

    Post

    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.

  8. #8
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    what about a midi?

    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.

  9. #9
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    what about a midi?

    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.

  10. #10
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    what about a midi?

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width