Closed zhjy8827 closed 2 years ago
Hi @zhjy8827 ;) I will make a pull request later but a quick fix for now is replacing this code from the pycaw.pycaw file: (your pycaw location: "D:\anaconda3\envs\pystream32\lib\site-packages\pycaw\pycaw.py")
class IAudioSessionControl(IUnknown):
_iid_ = GUID('{F4B1A599-7266-4319-A8CA-E70ACB11E8CD}')
_methods_ = (
# HRESULT GetState ([out] AudioSessionState *pRetVal);
COMMETHOD([], HRESULT, 'NotImpl1'),
with the following:
class IAudioSessionControl(IUnknown):
_iid_ = GUID('{F4B1A599-7266-4319-A8CA-E70ACB11E8CD}')
_methods_ = (
# HRESULT GetState ([out] AudioSessionState *pRetVal);
COMMETHOD([], HRESULT, 'GetState',
(['out'], POINTER(DWORD), 'pRetVal')),
After that session.State
will return an int:
0 = AudioSessionStateInactive
1 = AudioSessionStateActive
2 = AudioSessionStateExpired
Yeah please go ahead with a pull request that address just this part. I'll have time to review/merge this weekend
it is done https://github.com/AndreMiras/pycaw/pull/37 😀
thx !!!
Fixed via #37, closing, thanks again TurboAnonym
code:
error:
https://docs.microsoft.com/en-us/windows/win32/api/audiopolicy/nn-audiopolicy-iaudiosessioncontrol2 The IAudioSessionControl2 interface inherits from IAudioSessionControl. I need to use getstate method,what should I do? https://docs.microsoft.com/en-us/windows/win32/api/audiopolicy/nf-audiopolicy-iaudiosessioncontrol-getstate