user187719
user187719

Reputation:

Controlling the volume while using the SndPlayAsync function on Windows Mobile 6

How on earth can you control the volume of the sound played using SndPlayAsync on Windows Mobile 6??

It seems like no one knows! The documentation doesn't mention anything regarding it... So either there's no way, or it is kept top secret...

In addition, I am aware of the possibility of using the Windows Media Player, but I rather not, if possible.

Thanks for any help!

Aviv.

Upvotes: 1

Views: 1154

Answers (2)

Muris
Muris

Reputation: 158

My suggestion is:

[DllImport("coredll.dll", SetLastError = true)]
protected static extern int waveOutSetVolume(IntPtr device, uint volume);

[DllImport("coredll.dll", SetLastError = true)]
internal static extern int waveOutGetVolume(IntPtr device, ref int volume);

And then you can call methods:

int before;
uint maxVol = uint.MaxValue; 
waveOutGetVolume(IntPtr.Zero, ref before);
waveOutSetVolume(IntPtr.Zero, maxVol);
//Do some playing
waveOutSetVolume(IntPtr.Zero, before);

You can debug for other values. This will set it to highest.

Hope it helps?

Upvotes: 2

MusiGenesis
MusiGenesis

Reputation: 75296

You need to use the mixer... API functions to set the master volume. Here is a code sample:

http://www.csharp-home.com/index/tiki-read_article.php?articleId=134

To use this code in your Windows Mobile application, you need to change "winmm.dll" to "coredll.dll". Also, these methods may not be supported in Windows Mobile, but I'm pretty sure they are.

Upvotes: 0

Related Questions