pub struct SystemAudioVolume;Expand description
Controls for the system volume.
Implementations§
Source§impl SystemAudioVolume
impl SystemAudioVolume
Sourcepub fn get_gain() -> f32
pub fn get_gain() -> f32
Get the current system volume.
Examples found in repository?
examples/system_audio_volume.rs (line 11)
10fn main() {
11 let original_gain = SystemAudioVolume::get_gain();
12 println!("System gain is currently set at {original_gain}");
13
14 delay();
15
16 println!("Halving the gain 🤫");
17 SystemAudioVolume::set_gain(original_gain / 2.0);
18
19 delay();
20
21 println!("Muting 🔇");
22 SystemAudioVolume::mute();
23
24 delay();
25
26 println!("Unmuting 🔊");
27 SystemAudioVolume::unmute();
28
29 delay();
30
31 print!("Putting it back to how you had it 🧹");
32 SystemAudioVolume::set_gain(original_gain);
33}Sourcepub fn set_gain(gain: f32)
pub fn set_gain(gain: f32)
Set the system volume.
Examples found in repository?
examples/system_audio_volume.rs (line 17)
10fn main() {
11 let original_gain = SystemAudioVolume::get_gain();
12 println!("System gain is currently set at {original_gain}");
13
14 delay();
15
16 println!("Halving the gain 🤫");
17 SystemAudioVolume::set_gain(original_gain / 2.0);
18
19 delay();
20
21 println!("Muting 🔇");
22 SystemAudioVolume::mute();
23
24 delay();
25
26 println!("Unmuting 🔊");
27 SystemAudioVolume::unmute();
28
29 delay();
30
31 print!("Putting it back to how you had it 🧹");
32 SystemAudioVolume::set_gain(original_gain);
33}Sourcepub fn mute()
pub fn mute()
Mute the system audio output.
Examples found in repository?
examples/system_audio_volume.rs (line 22)
10fn main() {
11 let original_gain = SystemAudioVolume::get_gain();
12 println!("System gain is currently set at {original_gain}");
13
14 delay();
15
16 println!("Halving the gain 🤫");
17 SystemAudioVolume::set_gain(original_gain / 2.0);
18
19 delay();
20
21 println!("Muting 🔇");
22 SystemAudioVolume::mute();
23
24 delay();
25
26 println!("Unmuting 🔊");
27 SystemAudioVolume::unmute();
28
29 delay();
30
31 print!("Putting it back to how you had it 🧹");
32 SystemAudioVolume::set_gain(original_gain);
33}Sourcepub fn unmute()
pub fn unmute()
Unmute the system audio output.
Examples found in repository?
examples/system_audio_volume.rs (line 27)
10fn main() {
11 let original_gain = SystemAudioVolume::get_gain();
12 println!("System gain is currently set at {original_gain}");
13
14 delay();
15
16 println!("Halving the gain 🤫");
17 SystemAudioVolume::set_gain(original_gain / 2.0);
18
19 delay();
20
21 println!("Muting 🔇");
22 SystemAudioVolume::mute();
23
24 delay();
25
26 println!("Unmuting 🔊");
27 SystemAudioVolume::unmute();
28
29 delay();
30
31 print!("Putting it back to how you had it 🧹");
32 SystemAudioVolume::set_gain(original_gain);
33}Auto Trait Implementations§
impl Freeze for SystemAudioVolume
impl RefUnwindSafe for SystemAudioVolume
impl Send for SystemAudioVolume
impl Sync for SystemAudioVolume
impl Unpin for SystemAudioVolume
impl UnwindSafe for SystemAudioVolume
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more