(newbie) how do i play a .wav file in VB.net? 
Author Message
 (newbie) how do i play a .wav file in VB.net?

when a correct answer is given i want applause.wav to sound

do i need to declare as object?
how do i inport the .wav file?

thanks in advance



Sat, 17 Sep 2005 03:51:37 GMT  
 (newbie) how do i play a .wav file in VB.net?
Hi Lee,

I found the following post which shows two different ways to play wav files:

Quote:


> > > Easiest way is to add the Windows Media Play COM control. Set its
> Visible
> > > property to False if you don't want to see it. Here's some sample
code:

> > > Private Sub playMediaFile(ByVal mediaFileName As String)
> > > With MediaPlayer
> > > .Stop()
> > > .FileName = String.Concat _
> > > (c_soundPath, "\", _
> > > mediaFileName)
> > > .Play()
> > > ' marker code here
> > > End With
> > > End Sub

> > > You can also use the PlaySound API Function:

> > > Private Declare Auto Function PlaySound Lib "winmm.dll" (ByVal
> > lpszSoundName
> > > As _
> > > String, ByVal hModule As Integer, ByVal dwFlags As Integer) As
Integer

> > > Private Sub playWave_Click(ByVal sender As System.Object, ByVal e As
> > > System.EventArgs) Handles playWave.Click

> > > Dim fileName As String = String.Concat(c_soundPath, "\",
> waveList.Text)
> > > Const SND_FILENAME As Integer = &H20000

> > > PlaySound(fileName, 0, SND_FILENAME)
> > > End Sub

> > > HTH,

> > > --
> > > Jeff Rhodes
> > > Author of "VBTrain.Net: Creating Computer and Web Based Training with
> > Visual
> > > Basic? .NET"
> > > www.vbtrain.net
> > > Home of the Shape and Graphical Text controls

Hope this helps,

Abel, VB Team
This posting is provided "AS IS" with no warranties, and confers no rights.



Sat, 17 Sep 2005 05:06:05 GMT  
 (newbie) how do i play a .wav file in VB.net?
Hello Lee,


Quote:
> when a correct answer is given i want applause.wav
> to sound

http://www.mentalis.org/soft/class.qpx?id=1

Regards,
Herfried K. Wagner



Sat, 17 Sep 2005 05:22:27 GMT  
 (newbie) how do i play a .wav file in VB.net?
remember im a newbie :o)
ok i have this now... do i simply put the folders in my
WINDOWS/MICROSOFT.NET folder?

thanks



Quote:
> Hello Lee,


> > when a correct answer is given i want applause.wav
> > to sound

> http://www.mentalis.org/soft/class.qpx?id=1

> Regards,
> Herfried K. Wagner



Sat, 17 Sep 2005 05:45:01 GMT  
 (newbie) how do i play a .wav file in VB.net?
It must be to early for me to try this code, I can't seem to figure out what
does what, and what to change for it to work in my program :o(
is there bits of this code missing?



Quote:
> Hi Lee,

> I found the following post which shows two different ways to play wav
files:



> > > > Easiest way is to add the Windows Media Play COM control. Set its
> > Visible
> > > > property to False if you don't want to see it. Here's some sample
> code:

> > > > Private Sub playMediaFile(ByVal mediaFileName As String)
> > > > With MediaPlayer
> > > > .Stop()
> > > > .FileName = String.Concat _
> > > > (c_soundPath, "\", _
> > > > mediaFileName)
> > > > .Play()
> > > > ' marker code here
> > > > End With
> > > > End Sub

> > > > You can also use the PlaySound API Function:

> > > > Private Declare Auto Function PlaySound Lib "winmm.dll" (ByVal
> > > lpszSoundName
> > > > As _
> > > > String, ByVal hModule As Integer, ByVal dwFlags As Integer) As
> Integer

> > > > Private Sub playWave_Click(ByVal sender As System.Object, ByVal e As
> > > > System.EventArgs) Handles playWave.Click

> > > > Dim fileName As String = String.Concat(c_soundPath, "\",
> > waveList.Text)
> > > > Const SND_FILENAME As Integer = &H20000

> > > > PlaySound(fileName, 0, SND_FILENAME)
> > > > End Sub

> > > > HTH,

> > > > --
> > > > Jeff Rhodes
> > > > Author of "VBTrain.Net: Creating Computer and Web Based Training
with
> > > Visual
> > > > Basic? .NET"
> > > > www.vbtrain.net
> > > > Home of the Shape and Graphical Text controls

> Hope this helps,

> Abel, VB Team
> This posting is provided "AS IS" with no warranties, and confers no
rights.



Sat, 17 Sep 2005 05:47:02 GMT  
 (newbie) how do i play a .wav file in VB.net?
Lee,

   There's a code snippet I posted on devCity which shows you how you can
play a wave file (in a continuous loop or one or more times - plus how to
stop the continuous loop).

It is here:
http://www.vbcity.com/forums/topic.asp?tid=22676#RID67034

  In your project, you could use that code something along these lines:

At the point in your application where the correct answer is given, you
insert :-

code:
PlayAWave("C:\MyMusic\applause.wav")
end code:

  Obviously, the path needs to be changed to point to where the applause
file really resides.

   You can put all the code shown in the snippet on whichever form you are
using to test for answers.

   If you are going to distribute the finished application to other
computers, you would need to include the applause.wav file in your install
package, of course.

(Not quite sure if the last two paragraphs answer what you meant by your
question :- " ... do i simply put the folders in my > WINDOWS/MICROSOFT.NET
folder?")

   HTH


Quote:
> remember im a newbie :o)
> ok i have this now... do i simply put the folders in my
> WINDOWS/MICROSOFT.NET folder?

> thanks



> > Hello Lee,


> > > when a correct answer is given i want applause.wav
> > > to sound

> > http://www.mentalis.org/soft/class.qpx?id=1

> > Regards,
> > Herfried K. Wagner



Sat, 17 Sep 2005 20:51:08 GMT  
 (newbie) how do i play a .wav file in VB.net?
Hi JDP...
thanks for the help... It does work, however the course I have started in
VB.NET requires that Option Strict and Explicit is set to ON.

With Strict On the Constants need a value and '&HO', '&H1'  etc (have no
idea what these are for) VB returns, 'Type expected' the program locks up
when the .wav file plays, can you think of a way around this or should I
just wait untill im a little more experiencd B4 trying incorperate
multimendia files.

thanks


Quote:
> Lee,

>    There's a code snippet I posted on devCity which shows you how you can
> play a wave file (in a continuous loop or one or more times - plus how to
> stop the continuous loop).

> It is here:
> http://www.vbcity.com/forums/topic.asp?tid=22676#RID67034

>   In your project, you could use that code something along these lines:

> At the point in your application where the correct answer is given, you
> insert :-

> code:
> PlayAWave("C:\MyMusic\applause.wav")
> end code:

>   Obviously, the path needs to be changed to point to where the applause
> file really resides.

>    You can put all the code shown in the snippet on whichever form you are
> using to test for answers.

>    If you are going to distribute the finished application to other
> computers, you would need to include the applause.wav file in your install
> package, of course.

> (Not quite sure if the last two paragraphs answer what you meant by your
> question :- " ... do i simply put the folders in my >

WINDOWS/MICROSOFT.NET

- Show quoted text -

Quote:
> folder?")

>    HTH



> > remember im a newbie :o)
> > ok i have this now... do i simply put the folders in my
> > WINDOWS/MICROSOFT.NET folder?

> > thanks



> > > Hello Lee,


> > > > when a correct answer is given i want applause.wav
> > > > to sound

> > > http://www.mentalis.org/soft/class.qpx?id=1

> > > Regards,
> > > Herfried K. Wagner



Sat, 17 Sep 2005 23:22:38 GMT  
 (newbie) how do i play a .wav file in VB.net?

Hi Lee

  With Option Strict On, you will also have to include a Type in the
declaration of each
of the Constants.   (They do already have a value - that's the hex
values &H0, etc., but
they don't have a type declared).

   Change each of the Const declarations so that they include the
additional words'as long' in the declaration.
eg. the first one will have to read :
Const SND_SYNC As Long = &H0
and so on for each of them.

  BTW, you don't have to include all the constants listed in the code
snippet if you don't want to.   All that *must* be included are those
that are used by the code in your project.    The snippet includes them
all for info
so that users can tweak the core code to their own requirements.

   So if you only plan to use the PlayAWave Sub then you need only
declare the Consts SND_ASYNC and SND_NOSTOP.    

  Try those minor changes and I think it should work for you.

  If the app continues to lock up, then I'd ask you to clarify whether
you mean that it locks up and nothing happens (and you have to break out
of the running app and
restart) or if you mean that the wave file plays but the user is locked
out of the app until the wave file finishes playing.   It's a subtle but
important difference.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

  _alt.0
2K Download


Sun, 18 Sep 2005 04:35:40 GMT  
 (newbie) how do i play a .wav file in VB.net?

thanks...

Did what you suggested (with the const as Long)
and snipped some of the code.

it works fine with option strict on :o)

It locks up while the Applause.wav is playing (Program not responding appears in the caption bar) When the .wav file has finished the program then responds. I dont need to break, only wait...


  Hi Lee

    With Option Strict On, you will also have to include a Type in the
  declaration of each
  of the Constants.   (They do already have a value - that's the hex
  values &H0, etc., but
  they don't have a type declared).

     Change each of the Const declarations so that they include the
  additional words'as long' in the declaration.
  eg. the first one will have to read :
  Const SND_SYNC As Long = &H0
  and so on for each of them.

    BTW, you don't have to include all the constants listed in the code
  snippet if you don't want to.   All that *must* be included are those
  that are used by the code in your project.    The snippet includes them
  all for info
  so that users can tweak the core code to their own requirements.

     So if you only plan to use the PlayAWave Sub then you need only
  declare the Consts SND_ASYNC and SND_NOSTOP.    

    Try those minor changes and I think it should work for you.

    If the app continues to lock up, then I'd ask you to clarify whether
  you mean that it locks up and nothing happens (and you have to break out
  of the running app and
  restart) or if you mean that the wave file plays but the user is locked
  out of the app until the wave file finishes playing.   It's a subtle but
  important difference.

  *** Sent via Developersdex http://www.developersdex.com ***
  Don't just participate in USENET...get rewarded for it!



Sun, 18 Sep 2005 07:05:17 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. How do I play wav files etc in a VB.net program

2. How to play .wav file in vb.net

3. Play WAV file from VB6 and VB.NET

4. play wav files (newbie)

5. Playing .wav files in a ASP.NET Web Application

6. Playing sound (wav) in vb.net

7. Play WAV sounds in VB.NET

8. Detect Wav done playing w/API?

9. HELP: when is a .wav done playing?

10. Playing WAV files from VB programs

11. Playing WAV Files in a VB 6 Application

12. Play multiple wav files from VB

 

 
Powered by phpBB® Forum Software