Error when using pycaw with Ctypes
See original GitHub issueHi, I get the following error when using the function AudioUtilities.GetAllDevices(). Seems to be an issue with ctypes. It works on my other machine, but this particular laptop does not like it. Any ideas as to how to resolve this issue?
Running Windows10 Python 2.7.3 64 bit
error:
Traceback (most recent call last):
File "mvol.py", line 13, in <module>
devices = AudioUtilities.GetAllDevices()
File "C:\python_27_amd64\files\lib\site-packages\pycaw\pycaw.py", line 701, in GetAllDevices
devices.append(AudioUtilities.CreateDevice(dev))
File "C:\python_27_amd64\files\lib\site-packages\pycaw\pycaw.py", line 673, in CreateDevice
value = store.GetValue(pk)
_ctypes.COMError: (-536870389, None, (None, None, None, 0, None))
Here is the snippet of code that I am running:
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(
IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
print(volume.GetMute())
print(volume.GetMasterVolumeLevel())
print(volume.GetVolumeRange())
volume.SetMasterVolumeLevel(-20.0, None)
devices = AudioUtilities.GetAllDevices()
for d in devices:
print(str(d) + " " + str(d.state))
Let me know if I can try something to test, or if you need additional info.
Make sure to give enough information to help debugging your issue. Here are some hints:
- current requirements (pip freeze)
- OS version
- architecture
- Python version
- pycaw version
- project files
- exact stacktrace / accurate error message
- and so on
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
SyntaxError: multiple exception types must be parenthesized
I am a beginner and have a problem after installing pycaw for the audio control using python, on putting the basic ...
Read more >pycaw-rf · PyPI
Python Core Audio Windows Library, working for both Python2 and Python3. Install. Latest stable release: pip install pycaw. Development branch:
Read more >ctypes cast and from_address cause crash on Windows 10
Hi, Using cast() or from_address() to convert from c_void_p (or ... #arr = POINTER(c_ubyte).from_address(ptr) arr[0] # now crashes ``` Also ...
Read more >Windows Archive - TechOverflow -
You see an error message like the following one when running some Python code ... We can use the pycaw library to set...
Read more >Creating a Hand Gesture Volume Controller using Python and ...
pycaw depends on these two libraries. Ctypes provides C language compatible data types. Comtypes bases on the ctypes FFI(Foreign Function ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
cn u pls pls pls pls pls make it for mac 😦
ahh cn u pls tell me what it is