Skip to content

Examples

Fábián Varga edited this page Jul 24, 2022 · 1 revision
  1. First start off with
>>> import CoreAudio
>>> CoreAudio.init() # The module must always be initialised before you can use it properly.
True
  1. We can check whether the module is initialised like this:
>>> CoreAudio.ready()
True

Note: This is not required, just check what the init() function returned.

  1. Now, we can get the current volume level (in %)
>>> CoreAudio.getVolume()
17 # Current system volume level is set to 17%
  1. Now let's change it!
>>> CoreAudio.setVolume(10) # Set system volume to 10%`
True # Operation successful`
  1. We can also check if the output is muted;
>>> CoreAudio.getMute()
False # No it's not muted
  1. Let's change that!
>>> CoreAudio.setMute(True)
True # Operation successful

Side note: You can also use CoreAudio.mute() and CoreAudio.unmute(), which are aliases to CoreAudio.setMute(True) and CoreAudio.setMute(False)

Clone this wiki locally