Results 1 to 9 of 9

Thread: Playing .wav sound files

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Burnaby
    Posts
    3
    Hi there,

    I'm already using api to play .wav sounds one at a time, and my question is, is it possible to play two sounds at once? Also, is there a simple way to replay a sound when it's finished? Thanks!
    To be or not to be, that is the pencil. And yet also pointless.

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up

    i think this will do, yet it depands on the soundcard that you using. It should work for SoundBlaster SoundCard.

    Code:
    Option Explicit
    Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Private Declare Function PlaySound Lib "winmm.dll" 
    Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
    
    Private Const SND_ASYNC = &H1      ' Play asynchronously Private Const SND_NODEFAULT = &H2  ' Do not use default sound.
    
    Private Sub Form_Load()
        PlaySound "C:\welcome1.wav", 0&, SND_ASYNC Or SND_NODEFAULT
        PlaySound "C:\welcome2.wav", 0&, SND_ASYNC Or SND_NODEFAULT
    End Sub

  3. #3
    Guest
    Hi,
    I am using a Multimedia MCI control (MMControl) to play music. The problem is that I don't know how to automatically replay it. I mean with only 7 seconds of music repeat it constantly.
    Thank you very much.

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Saiz, you can use the MMControl1_PlayCompleted event in the MMControl to replay the audio file rite.

    Hope this can help you too.

  5. #5
    Guest
    Chris I tried something better, I copied the code from your previous reply and added the following:

    PlaySound "C:\Wmpaud9.wav", 0&, SND_ASYNC Or SND_LOOP

    Now it replay constantly.

    But still a problem: I don't know how to stop it!!!

    Any suggestion?

  6. #6
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Saiz, Here the sample on how to stop a wavw audio file play by the PlaySound API.

    Code:
    Option Explicit
    Private Const SND_PURGE = &H40       '  purge non-static events for task
    Private Const SND_ASYNC = &H1        '  play asynchronously
    Private Const SND_LOOP = &H8         '  loop the sound until next sndPlaySound
    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()
        PlaySound "C:\IR_BEGIN.WAV", 0&, SND_ASYNC Or SND_LOOP
    End Sub
    
    Private Sub Command2_Click()
        PlaySound "C:\IR_BEGIN.WAV", 0&, SND_PURGE
    End Sub

  7. #7
    Lively Member
    Join Date
    Mar 2000
    Posts
    84
    Where can I get Multimedia MCI control (MMControl) ??

    Thanks

    Andreas
    [email protected]

  8. #8
    Guest
    It's shipped with VB.

  9. #9
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    All you need is juz add the Multimedia control into your project.

    References|Component|Microsoft Myltimedia Control 6.0 (SP3)

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