Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Playing a wav File (xp)

    Hi, all

    I would like to play wav files from within code: something like:

    If condition is true then
    explosion.wav
    else
    splash.wav

    What would be the preferred method for so doing?

    TIA
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Playing a wav File (xp)

    Hi Rob,

    Put the following declarations at the top of a module:

    Public Const SND_ASYNC = &H1 ' play asynchronously
    Public Const SND_FILENAME = &H20000 ' name is a file name

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

    Use like this:

    If Condition = True Then
    PlaySound "C:.....Explosion.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
    Else
    PlaySound "C:......Splash.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
    End If

    Fill in the correct path to the sound files.

  3. #3
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Playing a wav File (xp)

    Hi Hans,

    I works a treat.

    Thanks again.
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

Posting Permissions

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