def on_connection_state_changed( session, logged_in_event, logged_out_event, backend): # Called from the pyspotify event loop, and not in an actor context. if session.connection.state is spotify.ConnectionState.LOGGED_OUT: logger.debug('Logged out of Spotify') logged_in_event.clear() logged_out_event.set() elif session.connection.state is spotify.ConnectionState.LOGGED_IN: logger.info('Logged in to Spotify in online mode') logged_in_event.set() logged_out_event.clear() backend.on_logged_in() elif session.connection.state is spotify.ConnectionState.DISCONNECTED: logger.info('Disconnected from Spotify') elif session.connection.state is spotify.ConnectionState.OFFLINE: logger.info('Logged in to Spotify in offline mode') logged_in_event.set() logged_out_event.clear()
def on_connection_state_changed(session, logged_in_event, logged_out_event, backend): # Called from the pyspotify event loop, and not in an actor context. if session.connection.state is spotify.ConnectionState.LOGGED_OUT: logger.debug('Logged out of Spotify') logged_in_event.clear() logged_out_event.set() elif session.connection.state is spotify.ConnectionState.LOGGED_IN: logger.info('Logged in to Spotify in online mode') logged_in_event.set() logged_out_event.clear() backend.on_logged_in() elif session.connection.state is spotify.ConnectionState.DISCONNECTED: logger.info('Disconnected from Spotify') elif session.connection.state is spotify.ConnectionState.OFFLINE: logger.info('Logged in to Spotify in offline mode') logged_in_event.set() logged_out_event.clear()