curiouswebster
asked on
Using an AxWindowsMediaPlayer in C#
I need to turn the mute to off on Windows XP, using C# and suspect that I need to instantiate an object similar to AxWindowsMediaPlayer.
Could someone please tell me what object in C#.NET I need to create for this and how to work with it??
thanks,
newbieweb
Could someone please tell me what object in C#.NET I need to create for this and how to work with it??
thanks,
newbieweb
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
waveOutSetVolume(IntPtr.Ze ro, 0); mutes sound.. Do not waste time for type casting. it is Zero (0) for mute
ASKER
I want to unmute sound.
Is that what this does:
waveOutSetVolume(IntPtr.Ze ro, NewVolumeAllChannels);
If so, please show me the code without typcasting to accomplish this.
thanks,
newbieweb
Is that what this does:
waveOutSetVolume(IntPtr.Ze
If so, please show me the code without typcasting to accomplish this.
thanks,
newbieweb
ASKER
what's the type of :
trackWave.Value
??
I am trying to create a variable inside the object to preseve the value returned by:
CalcVol / (ushort.MaxValue / 10);
trackWave.Value
??
I am trying to create a variable inside the object to preseve the value returned by:
CalcVol / (ushort.MaxValue / 10);
ASKER
Don't worry about my past two questions. I have you code compiling. BUT the mute does not come off when I explicitly set the Mute All option in Windows.
My program somehow causes the mute All to become active, and I want my program to remove the Mute.
I hope this cal would do that:
waveOutSetVolume(IntPtr.Ze ro, NewVolumeAllChannels);
but it does not. The value for NewVolumeAllChannels is:
4294639610
Thanks for the help,
newbieweb
My program somehow causes the mute All to become active, and I want my program to remove the Mute.
I hope this cal would do that:
waveOutSetVolume(IntPtr.Ze
but it does not. The value for NewVolumeAllChannels is:
4294639610
Thanks for the help,
newbieweb
the below link is exactly what you want. (more than it) download sample code and get necessary part inside it
http://msdn2.microsoft.com/en-us/library/aa719104(VS.71).aspx
http://msdn2.microsoft.com/en-us/library/aa719104(VS.71).aspx
ASKER
I started with your code and created a variabe for currentVolume to substitue for the variable trackWave.Value, but needed to typcast the uint to an int, but think that would totally change the values. Please take a look.
But all I really want is to turn mute off, and don't really think I need to be working with the volume.
Please take a look and let me know. I have an urgent need to keep the mute off for a management system where the mute keeps getting set to on.
Thanks for the help,
newbieweb
public partial class AdjustVolume
{
[DllImport("winmm.dll")]
public static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);
[DllImport("winmm.dll")]
public static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
uint currentVolume = 0;
public AdjustVolume()
{
// By the default set the volume to 0
uint CurrVol = 0;
// At this point, CurrVol gets assigned the volume
waveOutGetVolume(IntPtr.Ze
// Calculate the volume
ushort CalcVol = (ushort)(CurrVol & 0x0000ffff);
// Get the volume on a scale of 1 to 10 (to fit the trackbar)
currentVolume = (uint)CalcVol / (ushort.MaxValue / 10);
}
public void SetVolume()
{
// Calculate the volume that's being set
int NewVolume = ((ushort.MaxValue / 10) * (int)currentVolume); <<<<< typecasted it to int
// Set the same volume for both the left and the right channels
uint NewVolumeAllChannels = (((uint)NewVolume & 0x0000ffff) | ((uint)NewVolume << 16));
// Set the volume
waveOutSetVolume(IntPtr.Ze
}
}