CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2000
    Location
    The Netherlands, Overijssel
    Posts
    733

    How can i play a WAV file in VB?

    Please Help!@


    All At http://www.maxcode.com/
    ------------------------------------
    Clemens Timmermans (17-Year old)
    -------------------------------------
    - 'The Matrix has you, NEO' -(quote from: the Matrix)
    [url=http://www.maxcode.com/modules.php?name=Topics] Articles [url] | [url=http://www.maxcode.com/modules.php?name=Downloads&d_op=viewdownload&cid=4]
    Compilers [url] | [url=http://www.maxcode.com/modules.php?name=Downloads]Code Samples[url]

  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: How can i play a WAV file in VB?

    Use the MCI control. Set it's Wait property to False before executing the
    Play command. The program continues executing while the file plays.


    ' Open the device and play the sound.
    private Sub cmdPlay_Click()
    ' Disable this button.
    cmdPlay.Enabled = false

    ' set the file name.
    MMControl1.FileName = txtFilename.Text

    ' Open the MCI device.
    MMControl1.Wait = true
    MMControl1.Command = "Open"

    ' Play the sound without waiting.
    MMControl1.Notify = true
    MMControl1.Wait = false
    MMControl1.Command = "Play"

    ' Enable the timer.
    tmrSound.Enabled = true
    cmdStop.Enabled = true
    End Sub

    The MCI control's Done event fires when the control has finished playing
    the WAV file.


    ' Close the device when the sound is done.
    private Sub MMControl1_Done(NotifyCode as Integer)
    ' Close the device.
    MMControl1.Command = "Close"

    ' Disable the timer.
    tmrSound.Enabled = false
    cmdStop.Enabled = false

    ' Reenable the button.
    cmdPlay.Enabled = true
    End Sub





    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: You sure it was a question?

    ...Or was not it a way to tell us your site is back??

    Cheers,
    Cesare

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    Jan 2000
    Location
    The Netherlands, Overijssel
    Posts
    733

    Re: You sure it was a question?

    both


    All At http://www.maxcode.com/
    ------------------------------------
    Clemens Timmermans (17-Year old)
    -------------------------------------
    - 'The Matrix has you, NEO' -(quote from: the Matrix)
    [url=http://www.maxcode.com/modules.php?name=Topics] Articles [url] | [url=http://www.maxcode.com/modules.php?name=Downloads&d_op=viewdownload&cid=4]
    Compilers [url] | [url=http://www.maxcode.com/modules.php?name=Downloads]Code Samples[url]

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