コード例 #1
0
 /// <summary>Invoke the device volume mute changed event (if it has any listeners)</summary>
 protected void InvokeDeviceVolumeMuteChanged(bool muted, AudioOutputDevice audioOutputDevice)
 {
     if (onDeviceVolumeMuteChanged != null)
     {
         onDeviceVolumeMuteChanged(muted, audioOutputDevice);
     }
 }
コード例 #2
0
 /// <summary>Invoke the device volume changed event (if it has any listeners)</summary>
 protected void InvokeDeviceVolumeChanged(float volume, AudioOutputDevice audioOutputDevice)
 {
     if (onDeviceVolumeChanged != null)
     {
         onDeviceVolumeChanged(volume, audioOutputDevice);
     }
 }
コード例 #3
0
        /// <summary>Unmutes the device volume mute state for device with given id</summary>
        /// <param name="deviceID">The id of the device</param>
        /// <param name="sendCallback">Optional: Indicates whether to send an event callback, default is false</param>
        public static void UnmuteDeviceVolume(AudioOutputDevice audioOutputDevice, bool sendCallback = false)
        {
            NativeSystemVolume systemVolume = Instance.systemVolume;

            if (!systemVolume.ValidateDeviceID(audioOutputDevice.id))
            {
                return;
            }

            systemVolume.SetDeviceVolumeMute(false, audioOutputDevice.id, sendCallback);
        }
コード例 #4
0
        /// <summary>Indicates if the system volume is muted for the device with given ID</summary>
        public static bool IsDeviceVolumeMuted(AudioOutputDevice audioOutputDevice)
        {
            NativeSystemVolume systemVolume = Instance.systemVolume;

            if (!systemVolume.ValidateDeviceID(audioOutputDevice.id))
            {
                return(false);
            }

            return(systemVolume.IsDeviceVolumeMuted(audioOutputDevice.id));
        }
コード例 #5
0
        /// <summary>Gets the device volume for the device with given ID</summary>
        public static float GetDeviceVolume(AudioOutputDevice audioOutputDevice)
        {
            NativeSystemVolume systemVolume = Instance.systemVolume;

            if (!systemVolume.ValidateDeviceID(audioOutputDevice.id))
            {
                return(-1);
            }

            return(systemVolume.GetDeviceVolume(audioOutputDevice.id));
        }
コード例 #6
0
        /// <summary>Update the device volume mute states</summary>
        private void UpdateDeviceVolumeMutes()
        {
            int length = AudioOutputDevices.Length;

            for (int i = 0; i < length; i++)
            {
                AudioOutputDevice audioOutputDevice = AudioOutputDevices[i];
                bool lastMute = lastDeviceVolumeMutes[i];
                bool muted    = IsDeviceVolumeMuted(audioOutputDevice.id);
                if (lastMute != muted)
                {
                    InvokeDeviceVolumeMuteChanged(muted, audioOutputDevice);
                    lastDeviceVolumeMutes[i] = muted;
                }
            }
        }
コード例 #7
0
        /// <summary>Update the device volume states</summary>
        private void UpdateDeviceVolumes()
        {
            int length = AudioOutputDevices.Length;

            for (int i = 0; i < length; i++)
            {
                AudioOutputDevice audioOutputDevice = AudioOutputDevices[i];
                float             lastVolume        = lastDeviceVolumes[i];
                float             volume            = GetDeviceVolume(audioOutputDevice.id);
                if (lastVolume != volume)
                {
                    InvokeDeviceVolumeChanged(volume, audioOutputDevice);
                    lastDeviceVolumes[i] = volume;
                }
            }
        }