-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get list or Switch audio devices #49
Comments
@askruga i need this too |
These needs SetDefaultEndpoint(DeviceID, Role := 3)
{
; Undocumented COM-interface IPolicyConfig.
IPolicyConfig := ComObject("{870AF99C-171D-4F9E-AF0D-E63Df40c2BC9}", "{F8679F50-850A-41CF-9C72-430F290290C8}")
if (Role & 0x1)
ComCall(13, IPolicyConfig, "Str", DeviceID, "Int", 0) ; Default Device
if (Role & 0x2)
ComCall(13, IPolicyConfig, "Str", DeviceID, "Int", 2) ; Default Communication Device
} Stack overflow https://stackoverflow.com/questions/13054371/programmatically-switch-audio-devices-on-windows-7 Calling COM https://www.oreilly.com/library/view/python-programming-on/1565926218/ch05s02.html Tried to do it but I can't find the part that allows me to do the two-parameter version ComObject that allows passing in a CLSID and IID in w32com.client |
def switchOutput(deviceId, role):
policy_config = comtypes.CoCreateInstance(
pc.CLSID_PolicyConfigClient,
pc.IPolicyConfig,
comtypes.CLSCTX_ALL
)
policy_config.SetDefaultEndpoint(deviceId, role)
policy_config.Release() You can change audio devices using this function. You can get list of audio devices using |
how can I listen event of Switching current default audio device? |
Hey @KillerBOSS2019 |
Did you figure out what the |
It would be super helpful if you could throw togother a quick example of how to actually call this method. I can't find interface definitions for IPolicyConfig anywhere |
Luckily I have my project open source (: https://github.com/KillerBOSS2019/TouchPortal-Windows-MediaMixer/blob/main/src/audioUtil/policyconfig.py |
My project allows me to interface the audio mixer directly, changing individual application output/input and switching global audio devices |
Thanks for the link! I figured out the clsid thing on my own but was stuck at the IPolicyConfig. I'll have a look at your project |
This is exactly what I need 😄 |
This is excellent! I had started the process of implementing the |
Got it working! Thanks
|
Is there a way to get default audio input device change event from windows for python? |
@Dearex 1. I have tried to translate the program into python but no success. The dll is a simplified version of AudioSwitcher program. Basically a minimal required code to get it working. |
Would be cool if you can reference my project if you use part of my project. Not required (: |
Hi. Is it possible to:
1.Get a list of audio devices
2.Get current default audio device
3.Change the default device
by your lib?
Or maybe anyone have idea how do this?
Thanks for lib!
The text was updated successfully, but these errors were encountered: