473,320 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

When does a sound fininsh playing

Hi,

Does anyone know how to check for when a sound has finished playing?

I am currently using the SoundPlayer, there doesnt seem to be any
event for this - am I missing something?

Gary

Sep 17 '07 #1
4 1659
gazza67 wrote:
Does anyone know how to check for when a sound has finished playing?

I am currently using the SoundPlayer, there doesnt seem to be any
event for this - am I missing something?
I believe you can call PlaySync() and that will not return until the
sound has finished. If you want async behavior while knowing when the
sound has finished playing, then use a worker thread to actually do the
PlaySync() call, and raise an event or otherwise signal when the
PlaySync() method returns in that thread.

There are more complicated solutions using DirectSound or the WinMM
stuff (via p/invoke), but I think the above should work.

Pete
Sep 17 '07 #2
PlaySync, holds up your entire app, I dont want that to happen, I want
to be able to interrupt the play if a control is clicked.


On Sep 18, 8:59 am, Peter Duniho <NpOeStPe...@NnOwSlPiAnMk.comwrote:
gazza67 wrote:
Does anyone know how to check for when a sound has finished playing?
I am currently using the SoundPlayer, there doesnt seem to be any
event for this - am I missing something?

I believe you can call PlaySync() and that will not return until the
sound has finished. If you want async behavior while knowing when the
sound has finished playing, then use a worker thread to actually do the
PlaySync() call, and raise an event or otherwise signal when the
PlaySync() method returns in that thread.

There are more complicated solutions using DirectSound or the WinMM
stuff (via p/invoke), but I think the above should work.

Pete

Sep 17 '07 #3
Please disregard my last post, I see what you are saying now, I will
try a worker thread as you describe.

Gary
On Sep 18, 9:32 am, gazza67 <garys...@gmail.comwrote:
PlaySync, holds up your entire app, I dont want that to happen, I want
to be able to interrupt the play if a control is clicked.

On Sep 18, 8:59 am, Peter Duniho <NpOeStPe...@NnOwSlPiAnMk.comwrote:
gazza67 wrote:
Does anyone know how to check for when a sound has finished playing?
I am currently using the SoundPlayer, there doesnt seem to be any
event for this - am I missing something?
I believe you can call PlaySync() and that will not return until the
sound has finished. If you want async behavior while knowing when the
sound has finished playing, then use a worker thread to actually do the
PlaySync() call, and raise an event or otherwise signal when the
PlaySync() method returns in that thread.
There are more complicated solutions using DirectSound or the WinMM
stuff (via p/invoke), but I think the above should work.
Pete

Sep 17 '07 #4
The thread got spit; a worker-thread example is in the other chain...

Sep 18 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Andrew Poulos | last post by:
As a follow on to the 'fun' I had with IE I'm now trying to play sounds using an Object tag (no Embed) in MZ. Sadly whenever 'playButton' gets clicked MZ says that "audObj.Play is not a function":...
1
by: Marco Krechting | last post by:
Hi All, I have a database with the timer function set to warn the user that arecord is due to expire. Is there a Win API that I can use so a loud warning will go off. Not this simpel beep in...
1
by: Lam | last post by:
how can I play sound file in a .aspx page written in C#? I try to use the code like the following. But whenI call the play function play("sound.wav", this.SND_ASYNC) my computer give out "be"...
5
by: djc | last post by:
what choices do I have to play sounds in a program using vb.net? Or, I guess if nothing vb specific what windows API(s) should I look at? I am interested to find out whats needed for playing short...
16
by: Chris Ianson | last post by:
Hi, is there a way to play a small sound snippet when a user clicks a certain hyperlink hotspot on an image? Thanks in advance.
4
by: Benzerari | last post by:
Hi All; Please, if any one knows the visual basic code, to be added to a Stop button in order to stop playing some sound of (*.Wav) type. I have achieved to find the code for start playing sound...
5
by: gazza67 | last post by:
Hi, Does anyone know how to check for when a sound has finished playing? I am currently using the SoundPlayer, there doesnt seem to be any event for this - am I missing something? Gary
3
by: thenath24 | last post by:
Hello all, I'm currently writing a 3D Game demo and i'm having trouble getting the program to play a sound and deal with a keystroke at the same time. If a sound is playing the program will...
3
by: Jack | last post by:
Hi, I'm writing a simple wav player (like winamp) and using the SoundPlayer class in c# 2005. Using winform buttons, I can begin playing the sound and stop half-way through the sound using:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.