Playing/Stoping a sound

G

Guest

Hi all,
I am using these 3 lines to play a sound:
1) using System.Runtime.InteropServices;

2) [DllImport("coredll.dll")]
protected static extern int PlaySound(string szSound, IntPtr hMod, int
flags);

3) PlaySound("FileName.wav", IntPtr.Zero, 0x20001);

But if i want to stop a running WAV file, how could i do that?
Thanks in advance
Regards

Tamer Hesham
 
P

Peter Foot [MVP]

If you call PlaySound with null (Nothing in VB) for the szSound argument it
will stop playing. You may wish to take a look at the source code for the
SoundPlayer class in the SDF as this has a full wrapper around PlaySound -
www.opennetcf.org/sdf/

Peter
 
G

Guest

Sorry for asking again, playing and stoping WAV file worked well, now i want
to decrease and increase volume, how could i do that?

Thanks in advance..
 
G

Guest

P/Invoke waveOutSetVolume. Again, take Peter's advice and look at the SDF -
it's in there.

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top