Ejemplo n.º 1
0
        // This will start listening for changes in master volume (and assign a delegate to be notified when there is a change)
        public static void InitMasterVolumeListener(OnMasterVolumeChangeDelegate onMasterVolumeChange)
        {
            EndMasterVolumeListener();

            _onMasterVolumeChangeDelegate = onMasterVolumeChange;

            MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();

            _deviceForMasterVolume = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
            _deviceForMasterVolume.AudioEndpointVolume.OnVolumeNotification += new AudioEndpointVolumeNotificationDelegate(_onMasterVolumeChange);

            // Set initial master volume
            if (onMasterVolumeChange != null)
            {
                onMasterVolumeChange(_deviceForMasterVolume.AudioEndpointVolume.MasterVolumeLevelScalar, _deviceForMasterVolume.AudioEndpointVolume.Mute);
            }
        }
Ejemplo n.º 2
0
        // This will start listening for changes in master volume (and assign a delegate to be notified when there is a change)
        public static void InitMasterVolumeListener(OnMasterVolumeChangeDelegate onMasterVolumeChange)
        {
            EndMasterVolumeListener();

            _onMasterVolumeChangeDelegate = onMasterVolumeChange;

            MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
            _deviceForMasterVolume = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
            _deviceForMasterVolume.AudioEndpointVolume.OnVolumeNotification += new AudioEndpointVolumeNotificationDelegate(_onMasterVolumeChange);

            // Set initial master volume
            if (onMasterVolumeChange != null)
                onMasterVolumeChange(_deviceForMasterVolume.AudioEndpointVolume.MasterVolumeLevelScalar, _deviceForMasterVolume.AudioEndpointVolume.Mute);
        }