|
|
 |
| VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

July 2nd, 2003, 07:00 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Playing a WAV without interupting sub
Hi all,
I have a routine that plays a wav. I call this routine from other routines. The problem that I have is that the calling sub ends up pausing while the wav is played before it completes. I am an amateur programmer. I was wondering if there is a way (separate thread?) to call the routine that plays the wav but have it NOT interupt the rest of my routine?
Thanks in advance.
Raymond Deux
|

July 3rd, 2003, 11:53 AM
|
|
Authorized User
|
|
Join Date: Jul 2003
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
When using the win32API to play a wav from VB NET you need to first declare the following...
'//Win32API
'//Both integer args and return were originally Longs - .NET Integer = vb6 Long
Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Integer, _
ByVal dwFlags As Integer) As Integer
Then you can make a sub....
Friend Sub PlayAudio(ByVal FileName As String)
'//call win32api function to play audio (wav) file alert
Dim retval As Integer
retval = PlaySound(FileName, 0, 1)
'last param is SND_SYNC as integer
'value set to 0 plays sound Synchronously (waits until sound ends before playing next)
'value set to 1 plays sound Asynchronously (does not wait to play next sound)
End Sub
in the comments above you'll see that the last param determines if sound waits or or doesn't. If you want you can modify the sub above to take that as a param as well. This is a snippet from an app I wrote for work. This should solve your problem, just use value of 1 to make app not wait for sound to finish. Threads shouldn't be necessary.
hope this helps
Tek
|

July 3rd, 2003, 02:28 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Tek,
Thank you. That did the trick. I had a declaration and sub similar to yours and I was running it in ASYNC mode. I guess somewhere, it did not work as I expected. Your code works great. Thanks again.
Ray
|

July 4th, 2003, 09:00 PM
|
|
Registered User
|
|
Join Date: Jun 2003
Location: Manila, Laguna, Philippines.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i am a beginner in vb.net can you share me the code of your routine that plays the wav, thank you
HEY_HEY
|

July 4th, 2003, 11:55 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The code is in this thread a few posts above.
|

July 5th, 2003, 11:24 AM
|
|
Authorized User
|
|
Join Date: Jul 2003
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
shadowpug,
No problem ! :) Glad to help
aldwincusi: as shadow said the code is a few posts up in this thread, just copy it.
peace
Tek
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |