Skip to content

Commit cc23833

Browse files
Remove rebase artifacts
1 parent 66e537d commit cc23833

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

amplipi/streams/spotify_connect.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ def _deactivate(self):
141141
logger.info(f'{self.name}: stopping player')
142142

143143
self.proc.terminate()
144-
self.proc2.terminate()
145-
self.proc3.terminate()
146144
if self.proc.wait(1) != 0:
147145
logger.info(f'{self.name}: killing player')
148146
self.proc.kill()
@@ -153,10 +151,6 @@ def _deactivate(self):
153151
logger.info(f'{self.name}: killing metadata reader')
154152
self.proc2.kill()
155153
self.proc2.communicate()
156-
if self.proc3.wait(1) != 0:
157-
logger.info(f'{self.name}: killing volume synchronizer')
158-
self.proc3.kill()
159-
self.proc3.communicate()
160154

161155
if self.volume_sync_process:
162156
self.volume_sync_process.terminate()
@@ -178,7 +172,6 @@ def _deactivate(self):
178172
self._disconnect()
179173
self.proc = None
180174
self.proc2 = None
181-
self.proc3 = None
182175

183176
def info(self) -> models.SourceInfo:
184177
source = models.SourceInfo(

streams/spotify_volume_handler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import websockets
88
import requests
99

10-
from volume_synchronizer import VolumeSynchronizer, StreamData
10+
from volume_synchronizer import VolumeSynchronizer, StreamData, VolEvents
1111
from spot_connect_meta import Event
1212

1313

@@ -21,8 +21,9 @@ class SpotifyData(StreamData):
2121
"""A class that watches and tracks changes to spotify-side volume"""
2222

2323
def __init__(self, api_port: int):
24-
self.api_port: int = api_port
2524
super().__init__()
25+
self.api_port: int = api_port
26+
"""What port is go-librespot running on? Typically set to 3678 + vsrc."""
2627

2728
async def watch_vol(self):
2829
"""Watch the go-librespot websocket endpoint for volume change events and update AmpliPi volume info accordingly"""
@@ -37,13 +38,13 @@ async def watch_vol(self):
3738
event = Event.from_json(json.loads(msg))
3839
if event.event_type == "volume":
3940
last_volume = float(self.volume) if self.volume is not None else None
40-
self.volume = event.data.value / 100 # AmpliPi volume is between 0 and 1, Spotify is between 0 and 100. Dividing by 100 is more accurate than multiplying by 100 due to floating point errors.
41+
self.volume = event.data.value / 100 # Translate spotify volume (0 - 100) to amplipi volume (0 - 1)
4142

4243
self.logger.debug(f"Spotify volume changed from {last_volume} to {self.volume}")
4344
if last_volume is not None and self.volume != last_volume:
44-
self.callback("stream_volume_changed")
45+
self.schedule_event(VolEvents.CHANGE_AMPLIPI)
4546
elif event.event_type == "will_play" and self.volume is None:
46-
self.callback("amplipi_volume_changed") # Intercept the event that occurs when a song starts playing and use that as a trigger for the initial state sync
47+
self.schedule_event(VolEvents.CHANGE_STREAM) # Intercept the event that occurs when a song starts playing and use that as a trigger for the initial state sync
4748

4849
except Exception as e:
4950
self.logger.exception(f"Error: {e}")
@@ -76,7 +77,6 @@ def set_vol(self, amplipi_volume: float, shared_volume: float) -> float:
7677
parser = argparse.ArgumentParser(description="Read metadata from a given URL and write it to a file.")
7778

7879
parser.add_argument("port", help="port that go-librespot is running on", type=int)
79-
parser.add_argument("stream_id", help="The stream's amplipi side stream_id", type=int)
8080
parser.add_argument("config_dir", help="The directory of the vsrc config", type=str)
8181
parser.add_argument("--debug", action="store_true", help="Change log level from WARNING to DEBUG")
8282

0 commit comments

Comments
 (0)