views:

402

answers:

3

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.

A: 

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.

MusiGenesis
A: 

Thanks for the response MusiGenesis, however, I am not able to use the mixer since I don't have any mixer devices.

When calling mixerGetNumDevs() I get 0. Which explains why every function I call returns an error code.

Any other ways to control the volume on windows mobile 6 without mixers?

Aviv Reznik
+1  A: 

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?

Muris