Results 1 to 7 of 7

Thread: play wav's

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    How do i get a .wav sound to play, I've tried this:

    In the general declarations:
    Private Const SND_ASYNC = &H1
    Private Const SND_NODEFAULT = &H1
    Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

    and in the form_load:

    strWavFile = App.Path & "\mywavfile.wav"
    Call sndPlaySound(strWavFile, SND_ASYNC And SND_NODEFAULT)

    end it doesn't seem to work. Can anyone help?

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'Play A sound
    'Paste this code into a bas module
    '
    'API Function to play the sound
    '
    Declare Function sndPlaySound Lib "winmm" Alias _
    "sndPlaySoundA" (ByVal lpszSoundName As String, _
    ByVal uFlags As Long) As Long
    '
    ' play synchronously (default)
        Public Const SND_SYNC = &H0
    ' play asynchronously
        Public Const SND_ASYNC = &H1
    ' loop the sound until next
        Public Const SND_LOOP = &H8
    
    '=====================================================
    
    'Paste this code into the main
    'from your main program (button or load or whatever):
    'call the function using your wave file & location..replace "A:\whoosh.wav"
    '
     Call sndPlaySound(ByVal "a:\whoosh.wav", SND_ASYNC)
    'to stop it playing
     call sndPlaySound("")
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Guest
    Use the PlaySound api function instead of the sndPlaySound api function.

    Code:
    Private Declare Function PlaySound Lib "winmm.dll" _
     Alias "PlaySoundA" (ByVal lpszName As String, ByVal _
    hModule As Long, ByVal dwFlags As Long) As Long
    
    Private Sub Command1_Click()
        'Play wav
        PlaySound "C:\MyFile.wav", 0&, &H1
    
    End Sub
    
    Private Sub Command2_Click()
        'Stop wav
        PlaySound "C:\MyFile.wav", 0&, &H4
        'or is it:
        'PlaySound " ", 0&, &H1
    End Sub

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    There is no difference in the sound effect..just that playsound is the latter version destined to replace sndSound
    The same deal as [Let X = 12] and [x = 12]..both work..one is just old...I must be showing my age..using old code.

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    they both work fine, it's just a choice of your preference!

    i think that's tautology?!?

    i.e

    it's free and complimentary?

  6. #6
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    sndPlaySound vs PlaySound

    I don't know if this has any relevence, but it's qiute obvious that the PlaySound function is a superset of the old sndPlaySound function involved with the early 16 bit windows. And when they made PlaySound it was made 32 bit. So you ask what the difference is, I tell you. sndPlaySound : 16 bit, PLaySound : 32 bit.
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  7. #7
    Megatron
    Guest
    Use the PlaySound api function instead of the sndPlaySound api function.
    There's no difference in simply playing a WAV file. The main difference is that PlaySound lets you play sounds stored as resources.

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