The PlayerStatus
class provides information about the current state of the Spotify player. It includes methods for accessing player state, device IDs, and queue information.
-
login:
Login
The login instance used for authentication. -
s_device_id:
Optional[str]
The device ID to use for the player. IfNone
, a new device ID will be generated.
Initializes the PlayerStatus
class with a login instance and optional device ID.
- Args:
login
:Login
The login instance for authentication.s_device_id
:Optional[str]
The device ID for the player (optional).
Refreshes the current state and device information from the Spotify API.
Gets the last saved state of the player.
-
Returns:
PlayerState
The last saved state of the player. -
Raises:
ValueError
if the player state could not be retrieved.
Gets the current state of the player.
-
Returns:
PlayerState
The current state of the player. -
Raises:
ValueError
if the player state could not be retrieved.
Gets the last saved device IDs of the player.
-
Returns:
Devices
The last saved device IDs. -
Raises:
ValueError
if the devices could not be retrieved or the active device ID is missing.
Gets the current device IDs of the player.
-
Returns:
Devices
The current device IDs. -
Raises:
ValueError
if the devices could not be retrieved.
Gets the active device ID of the player.
-
Returns:
str
The active device ID. -
Raises:
ValueError
if the active device ID could not be retrieved.
Gets the next song in the queue.
- Returns:
Track | None
The next song in the queue orNone
if the queue is empty.
Gets the next songs in the queue.
- Returns:
List[Track]
The list of next songs in the queue.
Gets the last played track.
- Returns:
Track | None
The last played track orNone
if no tracks have been played.
Gets the last played songs.
- Returns:
List[Track]
The list of last played songs.
The EventManager
class extends PlayerStatus
and adds functionality for subscribing to and managing events from the Spotify websocket.
-
login:
Login
The login instance used for authentication. -
s_device_id:
Optional[str]
The device ID to use for the player. IfNone
, a new device ID will be generated.
Initializes the EventManager
class, sets up the websocket listener, and starts it in a separate thread.
- Args:
login
:Login
The login instance for authentication.s_device_id
:Optional[str]
The device ID for the player (optional).
Decorator to subscribe a function to a Spotify websocket event.
-
Args:
event
:str
The event to subscribe to.
-
Returns:
Callable[..., Any]
The decorated function.
Unsubscribes a function from an event.
- Args:
event
:str
The event to unsubscribe from.func
:Callable[..., Any]
The function to unsubscribe.