Results 1 to 4 of 4

Thread: sndPlaySound

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2000
    Posts
    37
    How is sndPlaySound used?

  2. #2
    Guest
    Code:
    Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Global Const SND_ASYNC = &H1
    Global Const SND_NODEFAULT = &H2
    
    Sub Playwav(file)
    SoundName$ = file
    wFlags% = SND_ASYNC Or SND_NODEFAULT
    X% = sndPlaySound(SoundName$, wFlags%): NoFreeze% = DoEvents()
    End Sub

  3. #3
    Guest
    Use PlaySound instead. It's slightly more flexible.

    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 the WAV
        PlaySound "C:\MyFile.wav", 0&, &H1
    
    End Sub

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

    <?>


    Code:
    'same dog different sled
    'added how to stop the file from playing
    
    ' bas module code
    
    'API Function to play the sound 
    ' 
    Public Declare Function sndPlaySound Lib "winmm" Alias _ 
    "sndPlaySoundA" (ByVal lpszSoundName As String, _ 
    ByVal uFlags As Long) As Long 
    ' 
    ' play synchronously (default)..music finishes first 
    Public Const SND_SYNC = &H0 
    ' play asynchronously 
    Public Const SND_ASYNC = &H1 
    ' loop the sound until next 
    Public Const SND_LOOP = &H8 
    
    '<<<<<  form code  >>>>>>>>
    
    'this one plays and allows other events to take place
    'ie form can change and music will still be playing
    Private Sub Command1_Click()
       Call sndPlaySound(ByVal "c:\yourfolder\yourfile.wav", SND_ASYNC) 
    End Sub 
    
    'to stop it you send it nothing as a parameter
    Private Sub Command2_Click() 
       Call sndPlaySound(0,0)  
    End Sub

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

    ___ Adolf Jensen

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