none
Shell Launcher - Volume not working RRS feed

  • Question

  • I have a video conferencing kiosk application that is running on Windows Emedded 8.1 Standard, I set the application to use a shell launcher for the kiosk user, however when I am using the a the application as a shell I can no longer control the volume on the device. Although if I run the program using the default explorer shell the volume does work. I think that this may be a system wide thing because even the hard button on the device don't change the volume. Has anyone ever faced this issue, or can anyone make a suggested work around?

    Thanks Michael


    Michael Leitao

    Friday, October 16, 2015 12:58 PM

Answers

  • Willi, Thanks for the reply, I was using the SendMessage idea from that article and it wasn't working. It seems that the volume is directly dependent on explorer. I found that I could control the wave volume easier and ended up using the NAudio package from Nuget. If you are interested here is what ended up working for me.

    public void SetVolume(int level)
            {
                try
                {
                    NAudio.CoreAudioApi.MMDeviceEnumerator MMDE = new NAudio.CoreAudioApi.MMDeviceEnumerator();
                    NAudio.CoreAudioApi.MMDeviceCollection DevCol = MMDE.EnumerateAudioEndPoints(NAudio.CoreAudioApi.DataFlow.All, NAudio.CoreAudioApi.DeviceState.All);
                    //Loop through all devices
                    foreach (NAudio.CoreAudioApi.MMDevice dev in DevCol)
                    {
                        try
                        {
                            if (dev.State == NAudio.CoreAudioApi.DeviceState.Active)
                            {
                                var newVolume = (float)Math.Max(Math.Min(level, 100), 0) / (float)100;
                                
                                //Set at maximum volume
                                dev.AudioEndpointVolume.MasterVolumeLevelScalar = newVolume;

                                dev.AudioEndpointVolume.Mute = level == 0;

                                //Get its audio volume
                                //log.Write("Volume of " + dev.FriendlyName + " is " + dev.AudioEndpointVolume.MasterVolumeLevelScalar.ToString());
                            }
                            else
                            {
                                //log.Write("Ignoring device " + dev.FriendlyName + " with state " + dev.State);
                            }
                        }
                        catch (Exception ex)
                        {
                            log.Write(dev.FriendlyName + " could not be muted with error " + ex);
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.("Could not enumerate devices due to an excepion: " + ex.Message);
                }
            }


    Michael Leitao

    • Marked as answer by mleitao1977 Wednesday, October 21, 2015 11:13 AM
    Wednesday, October 21, 2015 11:10 AM

All replies

  • Do you have access to the source of the driver/application that should control the device? The problem might be in the way how this has been implemented:

    This article describes a method where SendMessage() is used to send WM_APPCOMMAND with APPCOMMAND_VOLUME* in the parameter. I'm not sure, but this sound like a message that goes to the application that also handles the speaker icon in the taskbar's try. In this case, such method will not work. Well, AFAIK SendMessage() does can only be used in application, not in drivers.

    Another (and unfortunately more complex) method I found here is to use the IMMDeviceCollection.

    Friday, October 16, 2015 4:12 PM
  • Willi, Thanks for the reply, I was using the SendMessage idea from that article and it wasn't working. It seems that the volume is directly dependent on explorer. I found that I could control the wave volume easier and ended up using the NAudio package from Nuget. If you are interested here is what ended up working for me.

    public void SetVolume(int level)
            {
                try
                {
                    NAudio.CoreAudioApi.MMDeviceEnumerator MMDE = new NAudio.CoreAudioApi.MMDeviceEnumerator();
                    NAudio.CoreAudioApi.MMDeviceCollection DevCol = MMDE.EnumerateAudioEndPoints(NAudio.CoreAudioApi.DataFlow.All, NAudio.CoreAudioApi.DeviceState.All);
                    //Loop through all devices
                    foreach (NAudio.CoreAudioApi.MMDevice dev in DevCol)
                    {
                        try
                        {
                            if (dev.State == NAudio.CoreAudioApi.DeviceState.Active)
                            {
                                var newVolume = (float)Math.Max(Math.Min(level, 100), 0) / (float)100;
                                
                                //Set at maximum volume
                                dev.AudioEndpointVolume.MasterVolumeLevelScalar = newVolume;

                                dev.AudioEndpointVolume.Mute = level == 0;

                                //Get its audio volume
                                //log.Write("Volume of " + dev.FriendlyName + " is " + dev.AudioEndpointVolume.MasterVolumeLevelScalar.ToString());
                            }
                            else
                            {
                                //log.Write("Ignoring device " + dev.FriendlyName + " with state " + dev.State);
                            }
                        }
                        catch (Exception ex)
                        {
                            log.Write(dev.FriendlyName + " could not be muted with error " + ex);
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.("Could not enumerate devices due to an excepion: " + ex.Message);
                }
            }


    Michael Leitao

    • Marked as answer by mleitao1977 Wednesday, October 21, 2015 11:13 AM
    Wednesday, October 21, 2015 11:10 AM