-
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
Implement RegisterAudioSessionNotification #27
Comments
Thanks for the report, maybe you could try your luck making a pull request implementing it 😉 |
Hello, I'm trying to implement this functionality, but I've got some problems which I can't solve myself. class IAudioSessionEvents(IUnknown): # https://docs.microsoft.com/en-us/windows/win32/coreaudio/audio-session-events
_iid_ = GUID('{b1136c83-b6b5-4add-98a5-a2df8eedf6fc}')
_methods_ = (
# HRESULT OnSimpleVolumeChanged(
# [in] float NewVolume,
# [in] BOOL NewMute,
# [in] LPCGUID EventContext);
COMMETHOD([], HRESULT, 'OnSimpleVolumeChanged',
(['in'], c_float, 'NewVolume'),
(['in'], DWORD, 'NewMute'),
(['in'], POINTER(GUID), 'EventContext')),
) and implemented Register and Unregister Audio Session Notification methods: # HRESULT RegisterAudioSessionNotification(
# [in] IAudioSessionEvents *NewNotifications);
COMMETHOD([], HRESULT, 'RegisterAudioSessionNotification',
(['in'], POINTER(IAudioSessionEvents), 'NewNotifications')),
# HRESULT UnregisterAudioSessionNotification(
# [in] IAudioSessionEvents *NewNotifications);
COMMETHOD([], HRESULT, 'UnregisterAudioSessionNotification',
(['in'], POINTER(IAudioSessionEvents), 'NewNotifications'))) Taking as an example class AudioSessionEvents(COMObject):
_com_interfaces_ = [IAudioSessionEvents]
def OnSimpleVolumeChanged(self, *args, **kwargs):
print('OnSimpleVolumeChanged event') I had thought everything was fine, but when I tried this code: callback = AudioSessionEvents()
sessions = AudioUtilities.GetAllSessions()
for session in sessions:
session._ctl.RegisterAudioSessionNotification(callback)
volume = session.SimpleAudioVolume
print("volume.GetMute(): %s" % volume.GetMute())
volume.SetMute(1, None) there is no "OnSimpleVolumeChanged event" message. |
Thats all what i could collect on this topic: https://github.com/TurboAnonym/pycaw/tree/develop/IAudioSessionEvents I made the nessesary changes in my pycaw.pycaw file in line 236 and 280
|
Make sure to give enough information to help debugging your issue.
Here are some hints:
currently, it stays unimplemented
link to docs: https://docs.microsoft.com/en-us/windows/win32/api/audiopolicy/nf-audiopolicy-iaudiosessioncontrol-registeraudiosessionnotification
pycaw/pycaw/pycaw.py
Lines 256 to 260 in f7bd1a9
Without this thing, it's impossible to listen upon audio session volume change :(
The text was updated successfully, but these errors were encountered: