Connection¶
-
class
spotify.connection.
Connection
(session)[source]¶ Connection controller.
You’ll never need to create an instance of this class yourself. You’ll find it ready to use as the
connection
attribute on theSession
instance.-
state
¶ The session’s current
ConnectionState
.The connection state involves two components, authentication and offline mode. The mapping is as follows
LOGGED_OUT
: not authenticated, offlineOFFLINE
: authenticated, offlineLOGGED_IN
: authenticated, onlineDISCONNECTED
: authenticated, offline, was previously online
Register listeners for the
spotify.SessionEvent.CONNECTION_STATE_UPDATED
event to be notified when the connection state changes.
-
type
¶ The session’s
ConnectionType
.Defaults to
ConnectionType.UNKNOWN
. Set to aConnectionType
value to tell libspotify what type of connection you’re using.This is used together with
allow_network
,allow_network_if_roaming
,allow_sync_over_wifi
, andallow_sync_over_mobile
to control offline syncing and network usage.
-
allow_network
¶ Whether or not network access is allowed at all.
Defaults to
True
. Setting this toFalse
turns on offline mode.
-
allow_network_if_roaming
¶ Whether or not network access is allowed if
type
is set toConnectionType.MOBILE_ROAMING
.Defaults to
False
.
-
allow_sync_over_wifi
¶ Whether or not offline syncing is allowed when
type
is set toConnectionType.WIFI
.Defaults to
True
.
-
allow_sync_over_mobile
¶ Whether or not offline syncing is allowed when
type
is set toConnectionType.MOBILE
, orallow_network_if_roaming
isTrue
andtype
is set toConnectionType.MOBILE_ROAMING
.Defaults to
True
.
-