Give SpotifySessionManager audio and backend proxies on construction
This commit is contained in:
parent
f88b7115d9
commit
53d6156227
@ -83,6 +83,7 @@ class SpotifyBackend(ThreadingActor, base.Backend):
|
||||
from .session_manager import SpotifySessionManager
|
||||
|
||||
logger.debug(u'Connecting to Spotify')
|
||||
spotify = SpotifySessionManager(self.username, self.password)
|
||||
spotify = SpotifySessionManager(self.username, self.password,
|
||||
audio=self.audio, backend=self.actor_ref.proxy())
|
||||
spotify.start()
|
||||
return spotify
|
||||
|
||||
@ -27,13 +27,13 @@ class SpotifySessionManager(BaseThread, PyspotifySessionManager):
|
||||
appkey_file = os.path.join(os.path.dirname(__file__), 'spotify_appkey.key')
|
||||
user_agent = 'Mopidy %s' % get_version()
|
||||
|
||||
def __init__(self, username, password):
|
||||
def __init__(self, username, password, audio, backend):
|
||||
PyspotifySessionManager.__init__(self, username, password)
|
||||
BaseThread.__init__(self)
|
||||
self.name = 'SpotifyThread'
|
||||
|
||||
self.audio = None
|
||||
self.backend = None
|
||||
self.audio = audio
|
||||
self.backend = backend
|
||||
|
||||
self.connected = threading.Event()
|
||||
self.session = None
|
||||
@ -44,19 +44,8 @@ class SpotifySessionManager(BaseThread, PyspotifySessionManager):
|
||||
self._initial_data_receive_completed = False
|
||||
|
||||
def run_inside_try(self):
|
||||
self.setup()
|
||||
self.connect()
|
||||
|
||||
def setup(self):
|
||||
audio_refs = ActorRegistry.get_by_class(audio.Audio)
|
||||
assert len(audio_refs) == 1, \
|
||||
'Expected exactly one running Audio instance.'
|
||||
self.audio = audio_refs[0].proxy()
|
||||
|
||||
backend_refs = ActorRegistry.get_by_class(Backend)
|
||||
assert len(backend_refs) == 1, 'Expected exactly one running backend.'
|
||||
self.backend = backend_refs[0].proxy()
|
||||
|
||||
def logged_in(self, session, error):
|
||||
"""Callback used by pyspotify"""
|
||||
if error:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user