Results 1 to 4 of 4

Thread: [RESOLVED] Paysound Function - Stopping a sound

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2008
    Posts
    36

    Resolved [RESOLVED] Paysound Function - Stopping a sound

    Hey all.

    I need some help on stopping a sound from playing (pausing it) in a VB6.0 project.

    So far, i've got the sound playing with the "Playsound" function. This is pretty much how i declared it :

    Code:
    Private Const SND_APPLICATION = &H80         '  look for application specific association
    Private Const SND_ALIAS = &H10000     '  name is a WIN.INI [sounds] entry
    Private Const SND_ALIAS_ID = &H110000    '  name is a WIN.INI [sounds] entry identifier
    Private Const SND_ASYNC = &H1         '  play asynchronously
    Private Const SND_FILENAME = &H20000     '  name is a file name
    Private Const SND_LOOP = &H8         '  loop the sound until next sndPlaySound
    Private Const SND_MEMORY = &H4         '  lpszSoundName points to a memory file
    Private Const SND_NODEFAULT = &H2         '  silence not default, if sound not found
    Private Const SND_NOSTOP = &H10        '  don't stop any currently playing sound
    Private Const SND_NOWAIT = &H2000      '  don't wait if the driver is busy
    Private Const SND_PURGE = &H40               '  purge non-static events for task
    Private Const SND_RESOURCE = &H40004     '  name is a resource name or atom
    Private Const SND_SYNC = &H0         '  play synchronously (default)
    Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

    And my code to make a sound play merely consists of this :

    Code:
    PlaySound (ThisDir + "\Project Sounds\DJ Shadow - Organ Donor.wav"), ByVal 0&, SND_FILENAME Or SND_ASYNC

    My problem is that if i want to change the track, say maybe i wanted to listen to some ACDC, it overlaps the original sound (in this case DJ shadow's Organ Donor.) I need to stop the DJ shadow sound and start the ACDC.

    So how could i stop the Sound?

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Paysound Function - Stopping a sound

    see if this helps,
    PlaySound ByVal 0&, ByVal 0&, SND_NODEFAULT Or SND_MEMORY

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2008
    Posts
    36

    Re: Paysound Function - Stopping a sound

    Got it. It works - you're a genious.

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: [RESOLVED] Paysound Function - Stopping a sound

    I know this isn't important at this time but I use

    sndPlaySound vbNullString, SND_NODEFAULT

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