/// <summary> /// Set the volume on the device /// </summary> /// <param name="level"></param> public void VolumeSet(float level) { if (deviceCommunication == null || volumeSetting == null) { return; } if (DateTime.Now.Ticks - latestVolumeChange.Ticks < 1000) { return; } latestVolumeChange = DateTime.Now; if (volumeSetting.level > level) { while (volumeSetting.level > level) { volumeSetting.level -= volumeSetting.stepInterval; } } if (volumeSetting.level < level) { while (volumeSetting.level < level) { volumeSetting.level += volumeSetting.stepInterval; } } if (level > 1) { level = 1; volumeSetting.level = level; } if (level < 0) { level = 0; volumeSetting.level = level; } deviceCommunication.VolumeSet(volumeSetting); latestVolumeSet = level; }
public void VolumeSet(float level) { if (!IsConnected()) { return; } if (lastVolumeChange != null && DateTime.Now.Ticks - lastVolumeChange.Ticks < 1000) { return; } lastVolumeChange = DateTime.Now; if (volumeSetting.level > level) { while (volumeSetting.level > level) { volumeSetting.level -= volumeSetting.stepInterval; } } if (volumeSetting.level < level) { while (volumeSetting.level < level) { volumeSetting.level += volumeSetting.stepInterval; } } if (level > 1) { level = 1; } if (level < 0) { level = 0; } volumeSetting.level = level; deviceCommunication.VolumeSet(volumeSetting); }