CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: playing waves

  1. #1
    Join Date
    Mar 2000
    Location
    Israel
    Posts
    24

    playing waves

    does anyone know how to play wave file, WITHOUT using any special control for it (with api maybe...)?


  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: playing waves

    Like this:

    '--[Form1.frm]------------------------
    option Explicit
    Const pathWavFiles = "C:\WinNT\Media\"
    private Sub Command1_Click()
    PlayWav "tada.wav"
    End Sub
    Sub PlayWav(SoundName as string)
    Dim tmpSoundName as string
    Dim wFlags%, X%
    tmpSoundName = pathWavFiles & SoundName
    wFlags% = SND_ASYNC Or SND_NODEFAULT
    X% = sndPlaySound(tmpSoundName, wFlags%)
    End Sub
    '-------------------------------------

    '--[Module1.bas]----------------------
    ' WAV Sound values
    Global Const SND_SYNC = &H0
    Global Const SND_ASYNC = &H1
    Global Const SND_NODEFAULT = &H2
    Global Const SND_LOOP = &H8
    Global Const SND_NOSTOP = &H10

    #If Win32 then
    public Declare Function sndPlaySound& _
    Lib "winmm.dll" Alias "sndPlaySoundA" _
    (byval lpszSoundName as string, byval uFlags as Long)
    #else
    public Declare Function sndPlaySound% _
    Lib "mmsystem.dll" (byval lpszSoundName _
    as string, byval uFlags as Integer)
    #End If 'WIN32
    '-------------------------------------




    hope this helps,

    John

    John Pirkey
    MCSD
    www.ShallowWaterSystems.com
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

  3. #3
    Join Date
    Feb 2000
    Location
    garden grove, california
    Posts
    64

    Re: playing waves

    'forms declarations:
    Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA"(ByVal lpszSoundName as String, ByVal uFlags as Long) As Long

    'CODE

    Dim filename as String
    Dim rc as Long
    filename = "C:\windows\media\the microsoft sound.wav"
    rc = sndPlaySound(filename, 1)

    ' put that peave of code ^ there in whatever you want when to play the wave file



    Subzero

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

Featured