Results 1 to 6 of 6

Thread: [2008]Custom Sounds

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    6

    [2008]Custom Sounds

    Hey,

    I wondered how I could play custom sounds, instead of systemsounds

    I want the start to be key binded

    Code:
     If e.KeyCode = Keys.C Then ()
    Could anyone help please?

    Kind regards,

    unknown666

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2008]Custom Sounds

    My.Computer.Audio.Play
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    6

    Re: [2008]Custom Sounds

    Quote Originally Posted by kasracer
    My.Computer.Audio.Play
    It keeps saying the directory doesn't exist..

    Code:
    If e.KeyCode = Keys.V Then My.Computer.Audio.Play(Application.StartupPath & "\bin\clap.wav")

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2008]Custom Sounds

    usually the exe is IN the bin folder, so that is where application.startuppath is going to point to.

    If your wav is in the same folder as the exe, then you should do

    Code:
    My.Computer.Audio.Play(Application.StartupPath & "\clap.wav")

  5. #5
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2008]Custom Sounds

    Also, make sure you're including the wave file in the project but having it set to be copied on build. This way you ensure that if you do a rebuild (which cleans the last build), you won't lose your audio.
    Quote Originally Posted by kleinma
    Code:
    My.Computer.Audio.Play(Application.StartupPath & "\clap.wav")
    Remove the slash and you're good to go. The slash should take you back to the root directory (so C:\) I believe. Regardless it's unnecessary when the executable is in the same folder as the audio.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    6

    Re: [2008]Custom Sounds

    Quote Originally Posted by kleinma
    usually the exe is IN the bin folder, so that is where application.startuppath is going to point to.

    If your wav is in the same folder as the exe, then you should do

    Code:
    My.Computer.Audio.Play(Application.StartupPath & "\clap.wav")
    Thanks! working now +rep

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