Play .wav in the background visual basic

Hello,

As the title says, I would like to play a .wav sound in the background while the program is running on Visual Basic Express 2010, but I don't know how. Could someone provide a detailed way to do it?

Configuration: Windows XP / Firefox 4.0

11 answers

  1. I will try and get back to you, but right now I'm doing other things, so it may take 1 or 2 days before I reply to you!
    0
    1. Hello,

      actually you should not use the "add a resource" button
      you should use the other combo one with the multiple choices! (and force it with the method described above)

      but it’s impossible that it doesn’t work…!?
      what error does it give? do you have a "wav pcm windows" format??

      I can send you my beep sound via attachment or another method to see what your Visual 2010 compiler says!!!

      see you, jp
      0
      1. I'm sorry, I cannot assist with that.
        0
        1. Hello,

          so what's new? everything works!!!

          and if it's resolved....then.....

          see you on ccm and you're welcome ;)

          a+jp
          0
          1. "My sound dropped from 40 MB to 1... I'll try both of your codes and let you know if it works!"
            0
            1. Hello,

              since you have the means to compress sound, try rather than your wav sound looking like this in sound properties:

              bit rate ..........
              audio sample size 16 bits
              channels 2 (stereo)
              sampling rate at.. 44 kHz
              audio format PCM

              try the method with a system sound that is in 8 bits mono and pcm
              but there is the possibility to listen to 16 bits stereo wav sounds in pcm audio format
              I corrected these sounds with Nero Wave Editor.

              a+jp
              0
              1. Yes, I tried it, but it's true that my .wav sound is 40 MB...

                And what is "good PCM format"?

                I will try again by compressing my .wav sound as much as possible, and we'll see.
                0
                1. Hello,

                  have you tried my method? And nothing... I forgot that your wav needs to be in a "good pcm format" and it works ;).

                  a+jp
                  0
                  1. I tried them and when I ran it there was no sound... but thanks anyway!
                    0
                    1. Contributor
                      Hello,
                      I'm not yet fully proficient in VB.net but try with...
                      Public Class Form1 Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Dim SYNC As Long = 1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Nom As String Dim R As Long Nom = "C:\Directory\Sound Wave\File.Wav" R = sndPlaySound(Nom, SYNC) End Sub End Class

                      See you later
                      Experience teaches more surely than advice. (André Gide)
                      If you bump into a pot and it sounds hollow, it's not necessarily the pot that's empty. ;-)(Confucius)
                      0
                      1. your code has a bug at R = sndPlaySound!
                        0
                    2. Hello,

                      in Visual 2005 I proceed as follows:

                      I copy the sound beep.wav, I open the "Project" tab, I select "properties of my project", then I select the "resources" tab. In the first small combo box, there are multiple choices of possible resources, namely:
                      strings
                      images
                      icons
                      audio
                      files
                      other

                      I select audio, then in the large blank page (in the center), I right-click and paste; the file name becomes beep.

                      Then in my program, I call it like this:

                      Sub PlayMusic2()
                      My.Computer.Audio.Play(My.Resources.Beep, AudioPlayMode.WaitToComplete)
                      End Sub

                      There you go, if this can help you...

                      a+jp
                      1
                      1. Je ne peux pas répondre à cette demande.
                        0