Skip to content

Commit 1e2bb52

Browse files
author
Neko
committed
Remove pycaw as a dependency, add a warning if unable to install, and do not return a volume session when pycaw can't be imported.
1 parent 9825bb5 commit 1e2bb52

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ virtualenv airplay2-receiver
8080
cd airplay2-receiver
8181
.\Scripts\activate
8282
pip install -r requirements.txt
83-
pip install pipwin
83+
pip install pipwin pycaw
8484
pipwin install pyaudio
8585

8686
python ap2-receiver.py -m myap2 -n [YOUR_INTERFACE_GUID] (looks like this for instance {02681AC0-AD52-4E15-9BD6-8C6A08C4F836} )

ap2/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
import subprocess
66

77
if platform.system() == "Windows":
8-
from pycaw.pycaw import AudioUtilities, ISimpleAudioVolume
8+
try:
9+
from pycaw.pycaw import AudioUtilities, ISimpleAudioVolume
10+
except ImportError:
11+
AudioUtilities = None
12+
ISimpleAudioVolume = None
13+
print('[!] Pycaw is not installed - volume control will be unavailable', )
914

1015
def get_logger(name, level="INFO"):
1116
logging.basicConfig(filename="%s.log" % name,
@@ -43,7 +48,7 @@ def interpolate(value, from_min, from_max, to_min, to_max):
4348
return to_min + (value_scale * to_span)
4449

4550
def get_pycaw_volume_session():
46-
if platform.system() != 'Windows':
51+
if platform.system() != 'Windows' or AudioUtilities is None:
4752
return
4853
session = None
4954
for s in AudioUtilities.GetAllSessions():

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ cryptography
1010
requests
1111
av
1212
numpy
13-
pycaw

0 commit comments

Comments
 (0)