Results 1 to 7 of 7

Thread: Stop Sound Now! (Resolved)

  1. #1

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472

    Stop Sound Now! (Resolved)

    Im using the following, which I got here, to play sound:

    VB Code:
    1. Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
    2.     (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    3.    
    4. Private Const SND_ASYNC = &H1
    5. Private Const SND_NODEFAULT = &H2
    6.  
    7. sndPlaySound "C:\Temp.wav", SND_ASYNC Or SND_NODEFAULT

    my question is simple.. how do you stop the sound once it has started. Surprising that no one included this in many of the posts I have looked for here regarding this...

    thanks
    sac
    Last edited by Sacofjoea; Oct 7th, 2002 at 04:51 AM.

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    I think I read somewhere that you just run the same code again, but with no filename:

    sndPlaySound "", SND_ASYNC Or SND_NODEFAULT
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    no luck with that

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    I've just checked in the API guide, it says you need to set the first parameter to NULL, eg:

    sndPlaySound vbNull, SND_ASYNC Or SND_NODEFAULT

  5. #5

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    hmm makes sense but isn't working, damn it

  6. #6
    Member
    Join Date
    Sep 2002
    Location
    Sydney, Australia
    Posts
    37
    Setting the filename to null to stop the sound will only work if the sound is being looped, ie, with the SND_LOOP flag.

    VB Code:
    1. 'start
    2. sndPlaySound "C:\Temp.wav", SND_ASYNC Or SND_NODEFAULT Or SND_LOOP
    3.  
    4. 'stop
    5. sndPlaySound vbNullString, SND_ASYNC Or SND_NODEFAULT
    Sunny

    * No trees were harmed in the making or sending of this message. However a great number of electrons were terribly inconvenienced.

  7. #7

    Thread Starter
    Hyperactive Member Sacofjoea's Avatar
    Join Date
    May 2000
    Location
    Never Never Land
    Posts
    472
    ahh thanks - works

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