/// <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); } }
/// <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); } }
/// <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); }
/// <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)); }
/// <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)); }
/// <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; } } }
/// <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; } } }