p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 2nd, 2003, 07:00 PM
Authorized User
Points: 112, Level: 2
Points: 112, Level: 2 Points: 112, Level: 2 Points: 112, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 3rd, 2003, 11:53 AM
Authorized User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old July 3rd, 2003, 02:28 PM
Authorized User
Points: 112, Level: 2
Points: 112, Level: 2 Points: 112, Level: 2 Points: 112, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old July 4th, 2003, 09:00 PM
Registered User
Points: 28, Level: 1
Points: 28, Level: 1 Points: 28, Level: 1 Points: 28, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Manila, Laguna, Philippines.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwincusi
Default

i am a beginner in vb.net can you share me the code of your routine that plays the wav, thank you

HEY_HEY
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old July 4th, 2003, 11:55 PM
Authorized User
Points: 112, Level: 2
Points: 112, Level: 2 Points: 112, Level: 2 Points: 112, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , .
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The code is in this thread a few posts above.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old July 5th, 2003, 11:24 AM
Authorized User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent,Plz help...Problem with playing wav msg Andisheh C# 2005 0 July 5th, 2007 05:43 AM
How to playing music in C#? Viet Hoang C# 2005 4 June 13th, 2006 04:51 AM
playing with textbox ninjai ASP.NET 1.0 and 1.1 Basics 1 September 24th, 2005 01:38 PM
Playing music in C# Fightfish C# 0 June 26th, 2005 09:09 AM
playing embedded video sentme_mail Flash (all versions) 0 November 14th, 2004 11:47 AM



All times are GMT -4. The time now is 04:51 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc