mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-06 10:09:33 +02:00
Fix librespot reconnect handling
This commit is contained in:
parent
6451ab5b8d
commit
be083d2e8e
2 changed files with 16 additions and 10 deletions
|
@ -2,7 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# This file is part of snapcast
|
# This file is part of snapcast
|
||||||
# Copyright (C) 2014-2022 Johannes Pohl
|
# Copyright (C) 2014-2024 Johannes Pohl
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -91,11 +91,13 @@ class LibrespotControl(object):
|
||||||
self._librespot_request_map = {}
|
self._librespot_request_map = {}
|
||||||
self._seek_offset = 0.0
|
self._seek_offset = 0.0
|
||||||
|
|
||||||
self.websocket = websocket.WebSocketApp("ws://" + self._params['librespot-host'] + ":" + str(self._params['librespot-port']) + "/events",
|
self.websocket = websocket.WebSocketApp(
|
||||||
on_message=self.on_ws_message,
|
url=f"ws://{self._params['librespot-host']}:{self._params['librespot-port']}/events",
|
||||||
on_error=self.on_ws_error,
|
on_message=self.on_ws_message,
|
||||||
on_open=self.on_ws_open,
|
on_error=self.on_ws_error,
|
||||||
on_close=self.on_ws_close)
|
on_open=self.on_ws_open,
|
||||||
|
on_close=self.on_ws_close
|
||||||
|
)
|
||||||
|
|
||||||
self.websocket_thread = threading.Thread(
|
self.websocket_thread = threading.Thread(
|
||||||
target=self.websocket_loop, args=())
|
target=self.websocket_loop, args=())
|
||||||
|
@ -105,9 +107,13 @@ class LibrespotControl(object):
|
||||||
def websocket_loop(self):
|
def websocket_loop(self):
|
||||||
logger.info("Started LibrespotControl loop")
|
logger.info("Started LibrespotControl loop")
|
||||||
while True:
|
while True:
|
||||||
self.websocket.run_forever()
|
try:
|
||||||
sleep(1)
|
self.websocket.run_forever()
|
||||||
logger.info("Ending LibrespotControl loop")
|
sleep(2)
|
||||||
|
except Exception as e:
|
||||||
|
logger.info(f"Exception: {str(e)}")
|
||||||
|
self.websocket.close()
|
||||||
|
# logger.info("Ending LibrespotControl loop")
|
||||||
|
|
||||||
def getMetaData(self, data):
|
def getMetaData(self, data):
|
||||||
data = json.loads(data)
|
data = json.loads(data)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# This file is part of snapcast
|
# This file is part of snapcast
|
||||||
# Copyright (C) 2014-2022 Johannes Pohl
|
# Copyright (C) 2014-2024 Johannes Pohl
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue