Gateway API¶
The gateway layer contains the queue, enum, error, and event-related runtime types.
The top-level sonolink.Client, sonolink.Node, and sonolink.Player
classes are documented on Core API.
Voice state¶
- class sonolink.PlayerConnectionState[source]¶
- Attributes
Represents the voice connection state for a
BasePlayer.This class is intended to be subclassed if you need to store extra metadata during the Discord handshake.
Websocket payloads¶
- class sonolink.gateway.schemas.PlayerState(_time: int, position: int, connected: bool, ping: int)[source]¶
Represents a Player state on a Player Update event.
- class sonolink.gateway.schemas.MemoryStats(free: int, used: int, allocated: int, reservable: int)[source]¶
- Attributes
Represents the stats of the memory of the machine received within a stats event.
- class sonolink.gateway.schemas.CPUStats(cores: int, system_load: float, lavalink_load: float)[source]¶
- Attributes
Represents the stats of the CPU of the machine received within a stats event.
- class sonolink.gateway.schemas.FrameStats(sent: int, nulled: int, deficit: int)[source]¶
Represents the audio frames stats of the players received within a stats event.
- class sonolink.gateway.schemas.StatsEvent(players: int, playing_players: int, uptime: int, memory: MemoryStats, cpu: CPUStats, frame_stats: FrameStats | None = None)[source]¶
- Attributes
Represents the statistics received every minute via the websocket.
- frame_stats: FrameStats | None¶
The frame stats of the node.
- memory: MemoryStats¶
The memory stats of the node.
Library adapters¶
These classes are the concrete Player implementations for each
supported Discord library. You will not normally instantiate them directly —
Player resolves the correct adapter automatically at runtime via
the SONOLINK_FRAMEWORK environment variable. They are documented here for
completeness and for users who need to type-annotate their voice channel references
precisely.
All three classes inherit the full public API of BasePlayer
(playback, queue, filters, volume, etc.) in addition to the members listed below.
- class sonolink.gateway.player._base.BasePlayer(*, node: Node | None = None, queue_mode: QueueMode = QueueMode.NORMAL, autoplay_settings: AutoPlaySettings | None = None, history_settings: HistorySettings | None = None, volume: int | None = None, paused: bool | None = None, filters: Filters | None = None)[source]¶
- AttributesMethods
- defcleanup
- asyncconnect
- asyncdisconnect
- defget_connection_state
- asyncmove_to
- asyncon_voice_server_update
- asyncon_voice_state_update
- asyncpause
- asyncplay
- asyncprevious
- asyncresume
- asyncseek
- asyncset_filters
- asyncset_volume
- asyncskip
- asyncstop
- asyncupdate
Abstract base class that defines the interface for a Lavalink player.
This class is library-agnostic and is intended to be subclassed to provide concrete implementations compatible with
discord.py, py-cord`,disnake, ornextcord. Each library-specific subclass is responsible for implementing the voice protocol integration (e.g., inheriting from the appropriateVoiceProtocolclass) and fulfilling the abstract methods defined here.The public API exposed by this class remains consistent across all three Discord library backends, allowing shared business logic, extensions, and third-party integrations to target
BasePlayerwithout coupling to any specific library.- Parameters:
node (
Node| None) – The Lavalink node to associate this player with. IfNone, the player will attempt to resolve an available node at connection time.queue_mode (
QueueMode) – The initial queue looping mode. Defaults toQueueMode.NORMAL.autoplay_settings (
AutoPlaySettings| None) – Configuration for the AutoPlay feature. IfNone, a default configuration is used. History must be enabled if AutoPlay is used.history_settings (
HistorySettings| None) – Configuration for queue history. IfNone, a default configuration is used.volume (
int| None) – The initial volume of the player (0–1000). Defaults to100.paused (
bool| None) – Whether the player should start in a paused state. Defaults toFalse.filters (
Filters| None) – The initial set of audio filters to apply. IfNone, an emptyFiltersinstance is used.
- guild¶
The guild this player is attached to. The concrete type depends on the underlying Discord library (e.g.
discord.Guild(discord.py),discord.Guild(py-cord),disnake.Guild(disnake), ornextcord.Guild(nextcord)).
- channel¶
The voice channel this player is currently connected to. The concrete type depends on the underlying Discord library.
- Type:
Any
- client¶
The Discord client instance driving this player. The concrete type depends on the underlying Discord library.
- Type:
Any
- abstractmethod cleanup() None[source]¶
Cleans the internal state of the Player. This is automatically called by the library when failures or disconnects occur.
If this is overridden, it must call the original
cleanup.
- async connect(*, timeout: float = 10.0, reconnect: bool = False, self_deaf: bool = False, self_mute: bool = False) None[source]¶
Connect this player to its assigned voice channel.
Called automatically by libraries after the player is instantiated. Manual invocation is not normally required.
- Parameters:
timeout (
float) – Seconds to wait for the Discord gateway handshake before raising. Defaults to10.0.reconnect (
bool) – Whether to attempt reconnection on failure. Defaults toFalse.self_deaf (
bool) – Whether to join the channel self-deafened. Defaults toFalse.self_mute (
bool) – Whether to join the channel self-muted. Defaults toFalse.
- async disconnect(*, force: bool = False) None[source]¶
Disconnect this player, destroy it on the Lavalink node, and clean up all internal state.
- Parameters:
force (
bool) – IfTrue, proceeds even if the player is not currently connected. Defaults toFalse.
- get_connection_state() PlayerConnectionState[source]¶
Return a
PlayerConnectionStateinstance for this player.Override this method to supply a custom connection state subclass with additional metadata relevant to your application.
- Return type:
PlayerConnectionState
- async move_to(node: Node, /) None[source]¶
Migrate this player to a different Lavalink node without interrupting playback.
- Parameters:
node (
Node) – The destination node.
- abstractmethod async on_voice_server_update(data: Any) None[source]¶
Handle a
VOICE_SERVER_UPDATEpayload from the Discord gateway.This provides the voice server token and endpoint required by the Lavalink node to establish or re-establish the audio stream. This method should be called by the library-specific subclass in response to the corresponding gateway event.
The
datadictionary is passed as a raw mapping so that this base class remains decoupled from any specific library’s type aliases. Subclasses may cast it to the appropriate typed dict for their library (e.g.,discord.types.voice.VoiceServerUpdate,disnake.types.voice.VoiceServerUpdate).- Parameters:
data (
Any) – The rawVOICE_SERVER_UPDATEpayload received from the Discord gateway.
- abstractmethod async on_voice_state_update(data: Any) None[source]¶
Handle a
VOICE_STATE_UPDATEpayload from the Discord gateway.This provides the session ID and channel ID required for the voice connection handshake with the Lavalink node. This method should be called by the library-specific subclass in response to the corresponding gateway event.
The
datadictionary is passed as a raw mapping so that this base class remains decoupled from any specific library’s type aliases. Subclasses may cast it to the appropriate typed dict for their library (e.g.,discord.types.voice.GuildVoiceState,disnake.types.voice.GuildVoiceState).- Parameters:
data (
Any) – The rawVOICE_STATE_UPDATEpayload received from the Discord gateway.
- async pause() None[source]¶
Set the pause state of the player.
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async play(track: Playable, /, *, start: int = 0, end: int | None = None, volume: int | None = None, paused: bool | None = None) Playable[source]¶
Begin playback of the specified track.
If a track is already playing, it is stopped and the currently playing track is added to history (if history is enabled) before the new track starts.
- Parameters:
track (
Playable) – The track to play.start (
int) – The position in milliseconds at which to begin playback. Defaults to0.end (
int| None) – The position in milliseconds at which to stop playback. IfNone, the track plays to completion. Defaults toNone.volume (
int| None) – Override the player volume for this track only. IfNone, the current player volume is used. Defaults toNone.paused (
bool| None) – IfTrue, the track begins in a paused state. IfNone, the player’s current pause state is preserved. Defaults toNone.
- Returns:
The track that was dispatched to the Lavalink node for playback.
- Return type:
- async previous() Playable[source]¶
Return to the most recently played track in the history.
The current track is pushed back to the front of the queue so it can be reached again via
skip(). The historical track then begins playing immediately.- Returns:
The historical track that is now playing.
- Return type:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
HistoryEmpty – If there is no previous track in the history.
- async resume() None[source]¶
Resume playback if the player is currently paused.
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async seek(position: int, /) None[source]¶
Seek to an arbitrary position within the current track.
- Parameters:
position (
int) – The target position in milliseconds. Must be within the bounds of the current track’s duration.- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async set_filters(filters: Filters, /, *, seek: bool = False) None[source]¶
Apply a new set of audio filters to this player.
- Parameters:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async set_volume(value: int, /) None[source]¶
Set the player’s output volume.
- Parameters:
value (
int) – The desired volume level, in the range0–1000.100is the default (unmodified) level.- Raises:
ValueError – If
valueis outside the range0–1000.RuntimeError – If the player is not connected to a node or an active session.
- async skip() Playable | None[source]¶
Skip the currently playing track and advance to the next one in the queue.
If the queue is empty and AutoPlay is enabled, a related track may be fetched automatically. If neither a queued nor an AutoPlay track is available, playback stops and
Noneis returned.- Returns:
The track that began playing after the skip, or
Noneif the player stopped due to an empty queue with no AutoPlay fallback.- Return type:
Playable| None- Raises:
RuntimeError – If the player is not connected to a node or an active session.
QueueEmpty – If the queue is empty and AutoPlay is disabled or yields no results.
- async stop(*, clear_queue: bool = False, clear_history: bool = False) None[source]¶
Stop the currently playing track.
This sends a stop request to the Lavalink node and resets the player’s internal position tracking and current track reference.
- Parameters:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async update(*, queue_mode: QueueMode | None = None, autoplay_settings: AutoPlaySettings | None = None, history_settings: HistorySettings | None = None, volume: int | None = None, filters: Filters | None = None) None[source]¶
Update the player’s configuration in-place.
Added in version 1.1.0.
- Parameters:
queue_mode (
QueueMode| None) – The new queue looping mode. IfNone, the current mode is preserved.autoplay_settings (
AutoPlaySettings| None) – New AutoPlay configuration. IfNone, the current settings are preserved.history_settings (
HistorySettings| None) – New history configuration. IfNone, the current settings are preserved.volume (
int| None) – New volume in the range0–1000. IfNone, the current volume is preserved.filters (
Filters| None) – New audio filters. IfNone, the current filters are preserved.
- property autoplay: AutoPlayMode¶
The current
AutoPlayModefor this player.When AutoPlay is enabled, the player will automatically fetch and enqueue related tracks when the queue is exhausted.
- Raises:
RuntimeError – When setting, if the player’s history is disabled (history is required for AutoPlay to function).
- property autoplay_settings: AutoPlaySettings¶
The current
AutoPlaySettingsfor this player.Can be mutated directly to update individual fields, or replaced entirely.
Added in version 1.1.0.
- Return type:
- channel: Any¶
- client: Any¶
- property current: Playable | None¶
The track that is currently playing, or
Noneif the player is idle.- Return type:
Playable| None
- property filters: Filters¶
The
Filterscurrently applied to this player.To apply new filters, use
set_filters()rather than mutating this object directly, so that the updated state is dispatched to the Lavalink node.- Return type:
- property guild: Any¶
The guild this player is associated with.
The concrete return type is the guild class of the underlying Discord library (e.g.
discord.Guild,disnake.Guild).- Raises:
RuntimeError – If the player has not yet been attached to a guild.
- property history_settings: HistorySettings¶
The current
HistorySettingsfor this player’s queue.Can be mutated directly to update individual fields, or replaced entirely.
Added in version 1.1.0.
- Return type:
- property node: Node¶
The
Nodethis player is currently attached to.- Raises:
RuntimeError – If the player is not currently attached to a node.
- property position: int¶
The estimated current playback position in milliseconds.
When the player is paused or has not yet started, this returns the last known position. Otherwise, it is calculated by interpolating the time elapsed since the last state update received from the Lavalink node.
- Returns:
Position in milliseconds.
- Return type:
- property queue: Queue¶
The
Queueassociated with this player.The queue manages both upcoming tracks and playback history. Tracks can be added with
queue.put()/queue.put_wait()and inspected or manipulated via the queue’s public API.- Return type:
Queue
- class sonolink.gateway.player.adapters._dpy.DpyPlayer(*args: Any, **kwargs: Any)[source]¶
Bases:
BasePlayer,VoiceProtocolA discord.py implementation of
BasePlayer.This class satisfies the
discord.VoiceProtocolcontract expected by discord.py’s voice connection machinery, whilst delegating all Lavalink playback logic to the handlers initialised byBasePlayer.There are two primary ways to create a player:
Class-pass — pass the class itself to
discord.abc.Connectable.connect(). discord.py will instantiate it by callingPlayer(client, channel):player = await voice_channel.connect(cls=Player)
Instance-pass — construct a pre-configured instance and pass it instead. discord.py will call
player(client, channel)which hits__call__():player = Player(node=some_node, volume=80) await voice_channel.connect(cls=player)
- Parameters:
node (
Node| None) – The Lavalink node to associate with this player. IfNone, an available node is resolved from the client’s node pool at connection time.queue_mode (
QueueMode) – The initial queue looping mode. Defaults toQueueMode.NORMAL.autoplay_settings (
AutoPlaySettings| None) – AutoPlay configuration.Noneuses the default configuration. History must be enabled when AutoPlay is active.history_settings (
HistorySettings| None) – History configuration.Noneuses the default configuration.volume (
int| None) – Initial volume in the range0–1000. Defaults to100.paused (
bool| None) – Whether the player should start in a paused state. Defaults toFalse.filters (
Filters| None) – Initial audio filters. Defaults to an emptyFiltersinstance.
- guild¶
The guild this player is attached to.
- Type:
- channel¶
The voice channel this player is currently connected to.
- client¶
The discord.py client driving this player.
- Type:
- cleanup() None[source]¶
Cleans the internal state of the Player. This is automatically called by the library when failures or disconnects occur.
If this is overridden, it must call the original
cleanup.
- async connect(*, timeout: float = 10.0, reconnect: bool = False, self_deaf: bool = False, self_mute: bool = False) None¶
Connect this player to its assigned voice channel.
Called automatically by libraries after the player is instantiated. Manual invocation is not normally required.
- Parameters:
timeout (
float) – Seconds to wait for the Discord gateway handshake before raising. Defaults to10.0.reconnect (
bool) – Whether to attempt reconnection on failure. Defaults toFalse.self_deaf (
bool) – Whether to join the channel self-deafened. Defaults toFalse.self_mute (
bool) – Whether to join the channel self-muted. Defaults toFalse.
- async disconnect(*, force: bool = False) None¶
Disconnect this player, destroy it on the Lavalink node, and clean up all internal state.
- Parameters:
force (
bool) – IfTrue, proceeds even if the player is not currently connected. Defaults toFalse.
- get_connection_state() PlayerConnectionState¶
Return a
PlayerConnectionStateinstance for this player.Override this method to supply a custom connection state subclass with additional metadata relevant to your application.
- Return type:
PlayerConnectionState
- async move_to(node: Node, /) None¶
Migrate this player to a different Lavalink node without interrupting playback.
- Parameters:
node (
Node) – The destination node.
- async on_voice_server_update(data: VoiceServerUpdate) None[source]¶
Handle a
VOICE_SERVER_UPDATEpayload from the Discord gateway.Provides the voice server token and endpoint to the Lavalink node so it can establish or re-establish the audio stream.
- Parameters:
data (
discord.types.voice.VoiceServerUpdate) – The raw payload received from the Discord gateway.
- async on_voice_state_update(data: GuildVoiceState) None[source]¶
Handle a
VOICE_STATE_UPDATEpayload from the Discord gateway.Provides the session ID and channel ID required for the voice connection handshake with the Lavalink node.
- Parameters:
data (
discord.types.voice.GuildVoiceState) – The raw payload received from the Discord gateway.
- async pause() None¶
Set the pause state of the player.
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async play(track: Playable, /, *, start: int = 0, end: int | None = None, volume: int | None = None, paused: bool | None = None) Playable¶
Begin playback of the specified track.
If a track is already playing, it is stopped and the currently playing track is added to history (if history is enabled) before the new track starts.
- Parameters:
track (
Playable) – The track to play.start (
int) – The position in milliseconds at which to begin playback. Defaults to0.end (
int| None) – The position in milliseconds at which to stop playback. IfNone, the track plays to completion. Defaults toNone.volume (
int| None) – Override the player volume for this track only. IfNone, the current player volume is used. Defaults toNone.paused (
bool| None) – IfTrue, the track begins in a paused state. IfNone, the player’s current pause state is preserved. Defaults toNone.
- Returns:
The track that was dispatched to the Lavalink node for playback.
- Return type:
- async previous() Playable¶
Return to the most recently played track in the history.
The current track is pushed back to the front of the queue so it can be reached again via
skip(). The historical track then begins playing immediately.- Returns:
The historical track that is now playing.
- Return type:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
HistoryEmpty – If there is no previous track in the history.
- async resume() None¶
Resume playback if the player is currently paused.
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async seek(position: int, /) None¶
Seek to an arbitrary position within the current track.
- Parameters:
position (
int) – The target position in milliseconds. Must be within the bounds of the current track’s duration.- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async set_filters(filters: Filters, /, *, seek: bool = False) None¶
Apply a new set of audio filters to this player.
- Parameters:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async set_volume(value: int, /) None¶
Set the player’s output volume.
- Parameters:
value (
int) – The desired volume level, in the range0–1000.100is the default (unmodified) level.- Raises:
ValueError – If
valueis outside the range0–1000.RuntimeError – If the player is not connected to a node or an active session.
- async skip() Playable | None¶
Skip the currently playing track and advance to the next one in the queue.
If the queue is empty and AutoPlay is enabled, a related track may be fetched automatically. If neither a queued nor an AutoPlay track is available, playback stops and
Noneis returned.- Returns:
The track that began playing after the skip, or
Noneif the player stopped due to an empty queue with no AutoPlay fallback.- Return type:
Playable| None- Raises:
RuntimeError – If the player is not connected to a node or an active session.
QueueEmpty – If the queue is empty and AutoPlay is disabled or yields no results.
- async stop(*, clear_queue: bool = False, clear_history: bool = False) None¶
Stop the currently playing track.
This sends a stop request to the Lavalink node and resets the player’s internal position tracking and current track reference.
- Parameters:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async update(*, queue_mode: QueueMode | None = None, autoplay_settings: AutoPlaySettings | None = None, history_settings: HistorySettings | None = None, volume: int | None = None, filters: Filters | None = None) None¶
Update the player’s configuration in-place.
Added in version 1.1.0.
- Parameters:
queue_mode (
QueueMode| None) – The new queue looping mode. IfNone, the current mode is preserved.autoplay_settings (
AutoPlaySettings| None) – New AutoPlay configuration. IfNone, the current settings are preserved.history_settings (
HistorySettings| None) – New history configuration. IfNone, the current settings are preserved.volume (
int| None) – New volume in the range0–1000. IfNone, the current volume is preserved.filters (
Filters| None) – New audio filters. IfNone, the current filters are preserved.
- property autoplay: AutoPlayMode¶
The current
AutoPlayModefor this player.When AutoPlay is enabled, the player will automatically fetch and enqueue related tracks when the queue is exhausted.
- Raises:
RuntimeError – When setting, if the player’s history is disabled (history is required for AutoPlay to function).
- property autoplay_settings: AutoPlaySettings¶
The current
AutoPlaySettingsfor this player.Can be mutated directly to update individual fields, or replaced entirely.
Added in version 1.1.0.
- Return type:
- channel: discord.abc.Connectable¶
- client: discord.Client¶
- property current: Playable | None¶
The track that is currently playing, or
Noneif the player is idle.- Return type:
Playable| None
- property filters: Filters¶
The
Filterscurrently applied to this player.To apply new filters, use
set_filters()rather than mutating this object directly, so that the updated state is dispatched to the Lavalink node.- Return type:
- property guild: Any¶
The guild this player is associated with.
The concrete return type is the guild class of the underlying Discord library (e.g.
discord.Guild,disnake.Guild).- Raises:
RuntimeError – If the player has not yet been attached to a guild.
- property history_settings: HistorySettings¶
The current
HistorySettingsfor this player’s queue.Can be mutated directly to update individual fields, or replaced entirely.
Added in version 1.1.0.
- Return type:
- property node: Node¶
The
Nodethis player is currently attached to.- Raises:
RuntimeError – If the player is not currently attached to a node.
- property position: int¶
The estimated current playback position in milliseconds.
When the player is paused or has not yet started, this returns the last known position. Otherwise, it is calculated by interpolating the time elapsed since the last state update received from the Lavalink node.
- Returns:
Position in milliseconds.
- Return type:
- property queue: Queue¶
The
Queueassociated with this player.The queue manages both upcoming tracks and playback history. Tracks can be added with
queue.put()/queue.put_wait()and inspected or manipulated via the queue’s public API.- Return type:
Queue
- class sonolink.gateway.player.adapters._pycord.PycordPlayer(*args: Any, **kwargs: Any)[source]¶
Bases:
BasePlayer,ClientA py-cord implementation of
BasePlayer.This class satisfies the
discord.voice.VoiceProtocolcontract expected by py-cord’s voice connection machinery, whilst delegating all Lavalink playback logic to the handlers initialised byBasePlayer.There are two primary ways to create a player:
Class-pass - pass the class itself to
discord.abc.Connectable.connect(). py-cord will instantiate it by callingPlayer(client, channel):player = await voice_channel.connect(cls=Player)
Instance-pass - construct a pre-configured instance and pass it instead. py-cord will call
player(client, channel)which hits__call__():player = Player(node=some_node, volume=80) await voice_channel.connect(cls=player)
- Parameters:
node (
Node| None) – The Lavalink node to associate with this player. IfNone, an available node is resolved from the client’s node pool at connection time.queue_mode (
QueueMode) – The initial queue looping mode. Defaults toQueueMode.NORMAL.autoplay_settings (
AutoPlaySettings| None) – AutoPlay configuration.Noneuses the default configuration. History must be enabled when AutoPlay is active.history_settings (
HistorySettings| None) – History configuration.Noneuses the default configuration.volume (
int| None) – Initial volume in the range0–1000. Defaults to100.paused (
bool| None) – Whether the player should start in a paused state. Defaults toFalse.filters (
Filters| None) – Initial audio filters. Defaults to an emptyFiltersinstance.
- guild¶
The guild this player is attached to.
- Type:
- channel¶
The voice channel this player is currently connected to.
- client¶
The py-cord client driving this player.
- Type:
- cleanup() None[source]¶
Cleans the internal state of the Player. This is automatically called by the library when failures or disconnects occur.
If this is overridden, it must call the original
cleanup.
- async connect(*, timeout: float = 10.0, reconnect: bool = False, self_deaf: bool = False, self_mute: bool = False) None¶
Connect this player to its assigned voice channel.
Called automatically by libraries after the player is instantiated. Manual invocation is not normally required.
- Parameters:
timeout (
float) – Seconds to wait for the Discord gateway handshake before raising. Defaults to10.0.reconnect (
bool) – Whether to attempt reconnection on failure. Defaults toFalse.self_deaf (
bool) – Whether to join the channel self-deafened. Defaults toFalse.self_mute (
bool) – Whether to join the channel self-muted. Defaults toFalse.
- async disconnect(*, force: bool = False) None¶
Disconnect this player, destroy it on the Lavalink node, and clean up all internal state.
- Parameters:
force (
bool) – IfTrue, proceeds even if the player is not currently connected. Defaults toFalse.
- get_connection_state() PlayerConnectionState¶
Return a
PlayerConnectionStateinstance for this player.Override this method to supply a custom connection state subclass with additional metadata relevant to your application.
- Return type:
PlayerConnectionState
- async move_to(node: Node, /) None¶
Migrate this player to a different Lavalink node without interrupting playback.
- Parameters:
node (
Node) – The destination node.
- async on_voice_server_update(data: VoiceServerUpdate) None[source]¶
Handle a
VOICE_SERVER_UPDATEpayload from the Discord gateway.This provides the voice server token and endpoint required by the Lavalink node to establish or re-establish the audio stream. This method should be called by the library-specific subclass in response to the corresponding gateway event.
The
datadictionary is passed as a raw mapping so that this base class remains decoupled from any specific library’s type aliases. Subclasses may cast it to the appropriate typed dict for their library (e.g.,discord.types.voice.VoiceServerUpdate,disnake.types.voice.VoiceServerUpdate).- Parameters:
data (
Any) – The rawVOICE_SERVER_UPDATEpayload received from the Discord gateway.
- async on_voice_state_update(data: VoiceStateUpdate) None[source]¶
Handle a
VOICE_STATE_UPDATEpayload from the Discord gateway.This provides the session ID and channel ID required for the voice connection handshake with the Lavalink node. This method should be called by the library-specific subclass in response to the corresponding gateway event.
The
datadictionary is passed as a raw mapping so that this base class remains decoupled from any specific library’s type aliases. Subclasses may cast it to the appropriate typed dict for their library (e.g.,discord.types.voice.GuildVoiceState,disnake.types.voice.GuildVoiceState).- Parameters:
data (
Any) – The rawVOICE_STATE_UPDATEpayload received from the Discord gateway.
- async pause() None¶
Set the pause state of the player.
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async play(track: Playable, /, *, start: int = 0, end: int | None = None, volume: int | None = None, paused: bool | None = None) Playable¶
Begin playback of the specified track.
If a track is already playing, it is stopped and the currently playing track is added to history (if history is enabled) before the new track starts.
- Parameters:
track (
Playable) – The track to play.start (
int) – The position in milliseconds at which to begin playback. Defaults to0.end (
int| None) – The position in milliseconds at which to stop playback. IfNone, the track plays to completion. Defaults toNone.volume (
int| None) – Override the player volume for this track only. IfNone, the current player volume is used. Defaults toNone.paused (
bool| None) – IfTrue, the track begins in a paused state. IfNone, the player’s current pause state is preserved. Defaults toNone.
- Returns:
The track that was dispatched to the Lavalink node for playback.
- Return type:
- async previous() Playable¶
Return to the most recently played track in the history.
The current track is pushed back to the front of the queue so it can be reached again via
skip(). The historical track then begins playing immediately.- Returns:
The historical track that is now playing.
- Return type:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
HistoryEmpty – If there is no previous track in the history.
- async resume() None¶
Resume playback if the player is currently paused.
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async seek(position: int, /) None¶
Seek to an arbitrary position within the current track.
- Parameters:
position (
int) – The target position in milliseconds. Must be within the bounds of the current track’s duration.- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async set_filters(filters: Filters, /, *, seek: bool = False) None¶
Apply a new set of audio filters to this player.
- Parameters:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async set_volume(value: int, /) None¶
Set the player’s output volume.
- Parameters:
value (
int) – The desired volume level, in the range0–1000.100is the default (unmodified) level.- Raises:
ValueError – If
valueis outside the range0–1000.RuntimeError – If the player is not connected to a node or an active session.
- async skip() Playable | None¶
Skip the currently playing track and advance to the next one in the queue.
If the queue is empty and AutoPlay is enabled, a related track may be fetched automatically. If neither a queued nor an AutoPlay track is available, playback stops and
Noneis returned.- Returns:
The track that began playing after the skip, or
Noneif the player stopped due to an empty queue with no AutoPlay fallback.- Return type:
Playable| None- Raises:
RuntimeError – If the player is not connected to a node or an active session.
QueueEmpty – If the queue is empty and AutoPlay is disabled or yields no results.
- async stop(*, clear_queue: bool = False, clear_history: bool = False) None¶
Stop the currently playing track.
This sends a stop request to the Lavalink node and resets the player’s internal position tracking and current track reference.
- Parameters:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async update(*, queue_mode: QueueMode | None = None, autoplay_settings: AutoPlaySettings | None = None, history_settings: HistorySettings | None = None, volume: int | None = None, filters: Filters | None = None) None¶
Update the player’s configuration in-place.
Added in version 1.1.0.
- Parameters:
queue_mode (
QueueMode| None) – The new queue looping mode. IfNone, the current mode is preserved.autoplay_settings (
AutoPlaySettings| None) – New AutoPlay configuration. IfNone, the current settings are preserved.history_settings (
HistorySettings| None) – New history configuration. IfNone, the current settings are preserved.volume (
int| None) – New volume in the range0–1000. IfNone, the current volume is preserved.filters (
Filters| None) – New audio filters. IfNone, the current filters are preserved.
- property autoplay: AutoPlayMode¶
The current
AutoPlayModefor this player.When AutoPlay is enabled, the player will automatically fetch and enqueue related tracks when the queue is exhausted.
- Raises:
RuntimeError – When setting, if the player’s history is disabled (history is required for AutoPlay to function).
- property autoplay_settings: AutoPlaySettings¶
The current
AutoPlaySettingsfor this player.Can be mutated directly to update individual fields, or replaced entirely.
Added in version 1.1.0.
- Return type:
- channel: discord.abc.Connectable¶
- client: discord.Client¶
- property current: Playable | None¶
The track that is currently playing, or
Noneif the player is idle.- Return type:
Playable| None
- property filters: Filters¶
The
Filterscurrently applied to this player.To apply new filters, use
set_filters()rather than mutating this object directly, so that the updated state is dispatched to the Lavalink node.- Return type:
- property guild: Any¶
The guild this player is associated with.
The concrete return type is the guild class of the underlying Discord library (e.g.
discord.Guild,disnake.Guild).- Raises:
RuntimeError – If the player has not yet been attached to a guild.
- property history_settings: HistorySettings¶
The current
HistorySettingsfor this player’s queue.Can be mutated directly to update individual fields, or replaced entirely.
Added in version 1.1.0.
- Return type:
- property node: Node¶
The
Nodethis player is currently attached to.- Raises:
RuntimeError – If the player is not currently attached to a node.
- property position: int¶
The estimated current playback position in milliseconds.
When the player is paused or has not yet started, this returns the last known position. Otherwise, it is calculated by interpolating the time elapsed since the last state update received from the Lavalink node.
- Returns:
Position in milliseconds.
- Return type:
- property queue: Queue¶
The
Queueassociated with this player.The queue manages both upcoming tracks and playback history. Tracks can be added with
queue.put()/queue.put_wait()and inspected or manipulated via the queue’s public API.- Return type:
Queue
- class sonolink.gateway.player.adapters._disnake.DisnakePlayer(*args: Any, **kwargs: Any)[source]¶
Bases:
BasePlayer,VoiceProtocolA disnake implementation of
BasePlayer.This class satisfies the
disnake.VoiceProtocolcontract expected by disnake’s voice connection machinery, whilst delegating all Lavalink playback logic to the handlers initialised byBasePlayer.There are two primary ways to create a player:
Class-pass — pass the class itself to
disnake.abc.Connectable.connect(). disnake will instantiate it by callingPlayer(client, channel):player = await voice_channel.connect(cls=Player)
Instance-pass — construct a pre-configured instance and pass it instead. disnake will call
player(client, channel)which hits__call__():player = Player(node=some_node, volume=80) await voice_channel.connect(cls=player)
- Parameters:
node (
Node| None) – The Lavalink node to associate with this player. IfNone, an available node is resolved from the client’s node pool at connection time.queue_mode (
QueueMode) – The initial queue looping mode. Defaults toQueueMode.NORMAL.autoplay_settings (
AutoPlaySettings| None) – AutoPlay configuration.Noneuses the default configuration. History must be enabled when AutoPlay is active.history_settings (
HistorySettings| None) – History configuration.Noneuses the default configuration.volume (
int| None) – Initial volume in the range0–1000. Defaults to100.paused (
bool| None) – Whether the player should start in a paused state. Defaults toFalse.filters (
Filters| None) – Initial audio filters. Defaults to an emptyFiltersinstance.
- guild¶
The guild this player is attached to.
- Type:
- channel¶
The voice channel this player is currently connected to.
- client¶
The disnake client driving this player.
- Type:
- cleanup() None[source]¶
Cleans the internal state of the Player. This is automatically called by the library when failures or disconnects occur.
If this is overridden, it must call the original
cleanup.
- async connect(*, timeout: float = 10.0, reconnect: bool = False, self_deaf: bool = False, self_mute: bool = False) None¶
Connect this player to its assigned voice channel.
Called automatically by libraries after the player is instantiated. Manual invocation is not normally required.
- Parameters:
timeout (
float) – Seconds to wait for the Discord gateway handshake before raising. Defaults to10.0.reconnect (
bool) – Whether to attempt reconnection on failure. Defaults toFalse.self_deaf (
bool) – Whether to join the channel self-deafened. Defaults toFalse.self_mute (
bool) – Whether to join the channel self-muted. Defaults toFalse.
- async disconnect(*, force: bool = False) None¶
Disconnect this player, destroy it on the Lavalink node, and clean up all internal state.
- Parameters:
force (
bool) – IfTrue, proceeds even if the player is not currently connected. Defaults toFalse.
- get_connection_state() PlayerConnectionState¶
Return a
PlayerConnectionStateinstance for this player.Override this method to supply a custom connection state subclass with additional metadata relevant to your application.
- Return type:
PlayerConnectionState
- async move_to(node: Node, /) None¶
Migrate this player to a different Lavalink node without interrupting playback.
- Parameters:
node (
Node) – The destination node.
- async on_voice_server_update(data: VoiceServerUpdateEvent) None[source]¶
Handle a
VOICE_SERVER_UPDATEpayload from the Discord gateway.Provides the voice server token and endpoint to the Lavalink node so it can establish or re-establish the audio stream.
- Parameters:
data (
disnake.types.voice.VoiceServerUpdate) – The raw payload received from the Discord gateway.
- async on_voice_state_update(data: GuildVoiceState) None[source]¶
Handle a
VOICE_STATE_UPDATEpayload from the Discord gateway.Provides the session ID and channel ID required for the voice connection handshake with the Lavalink node.
- Parameters:
data (
disnake.types.voice.GuildVoiceState) – The raw payload received from the Discord gateway.
- async pause() None¶
Set the pause state of the player.
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async play(track: Playable, /, *, start: int = 0, end: int | None = None, volume: int | None = None, paused: bool | None = None) Playable¶
Begin playback of the specified track.
If a track is already playing, it is stopped and the currently playing track is added to history (if history is enabled) before the new track starts.
- Parameters:
track (
Playable) – The track to play.start (
int) – The position in milliseconds at which to begin playback. Defaults to0.end (
int| None) – The position in milliseconds at which to stop playback. IfNone, the track plays to completion. Defaults toNone.volume (
int| None) – Override the player volume for this track only. IfNone, the current player volume is used. Defaults toNone.paused (
bool| None) – IfTrue, the track begins in a paused state. IfNone, the player’s current pause state is preserved. Defaults toNone.
- Returns:
The track that was dispatched to the Lavalink node for playback.
- Return type:
- async previous() Playable¶
Return to the most recently played track in the history.
The current track is pushed back to the front of the queue so it can be reached again via
skip(). The historical track then begins playing immediately.- Returns:
The historical track that is now playing.
- Return type:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
HistoryEmpty – If there is no previous track in the history.
- async resume() None¶
Resume playback if the player is currently paused.
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async seek(position: int, /) None¶
Seek to an arbitrary position within the current track.
- Parameters:
position (
int) – The target position in milliseconds. Must be within the bounds of the current track’s duration.- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async set_filters(filters: Filters, /, *, seek: bool = False) None¶
Apply a new set of audio filters to this player.
- Parameters:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async set_volume(value: int, /) None¶
Set the player’s output volume.
- Parameters:
value (
int) – The desired volume level, in the range0–1000.100is the default (unmodified) level.- Raises:
ValueError – If
valueis outside the range0–1000.RuntimeError – If the player is not connected to a node or an active session.
- async skip() Playable | None¶
Skip the currently playing track and advance to the next one in the queue.
If the queue is empty and AutoPlay is enabled, a related track may be fetched automatically. If neither a queued nor an AutoPlay track is available, playback stops and
Noneis returned.- Returns:
The track that began playing after the skip, or
Noneif the player stopped due to an empty queue with no AutoPlay fallback.- Return type:
Playable| None- Raises:
RuntimeError – If the player is not connected to a node or an active session.
QueueEmpty – If the queue is empty and AutoPlay is disabled or yields no results.
- async stop(*, clear_queue: bool = False, clear_history: bool = False) None¶
Stop the currently playing track.
This sends a stop request to the Lavalink node and resets the player’s internal position tracking and current track reference.
- Parameters:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async update(*, queue_mode: QueueMode | None = None, autoplay_settings: AutoPlaySettings | None = None, history_settings: HistorySettings | None = None, volume: int | None = None, filters: Filters | None = None) None¶
Update the player’s configuration in-place.
Added in version 1.1.0.
- Parameters:
queue_mode (
QueueMode| None) – The new queue looping mode. IfNone, the current mode is preserved.autoplay_settings (
AutoPlaySettings| None) – New AutoPlay configuration. IfNone, the current settings are preserved.history_settings (
HistorySettings| None) – New history configuration. IfNone, the current settings are preserved.volume (
int| None) – New volume in the range0–1000. IfNone, the current volume is preserved.filters (
Filters| None) – New audio filters. IfNone, the current filters are preserved.
- property autoplay: AutoPlayMode¶
The current
AutoPlayModefor this player.When AutoPlay is enabled, the player will automatically fetch and enqueue related tracks when the queue is exhausted.
- Raises:
RuntimeError – When setting, if the player’s history is disabled (history is required for AutoPlay to function).
- property autoplay_settings: AutoPlaySettings¶
The current
AutoPlaySettingsfor this player.Can be mutated directly to update individual fields, or replaced entirely.
Added in version 1.1.0.
- Return type:
- channel: disnake.abc.Connectable¶
- client: disnake.Client¶
- property current: Playable | None¶
The track that is currently playing, or
Noneif the player is idle.- Return type:
Playable| None
- property filters: Filters¶
The
Filterscurrently applied to this player.To apply new filters, use
set_filters()rather than mutating this object directly, so that the updated state is dispatched to the Lavalink node.- Return type:
- property guild: Any¶
The guild this player is associated with.
The concrete return type is the guild class of the underlying Discord library (e.g.
discord.Guild,disnake.Guild).- Raises:
RuntimeError – If the player has not yet been attached to a guild.
- property history_settings: HistorySettings¶
The current
HistorySettingsfor this player’s queue.Can be mutated directly to update individual fields, or replaced entirely.
Added in version 1.1.0.
- Return type:
- property node: Node¶
The
Nodethis player is currently attached to.- Raises:
RuntimeError – If the player is not currently attached to a node.
- property position: int¶
The estimated current playback position in milliseconds.
When the player is paused or has not yet started, this returns the last known position. Otherwise, it is calculated by interpolating the time elapsed since the last state update received from the Lavalink node.
- Returns:
Position in milliseconds.
- Return type:
- property queue: Queue¶
The
Queueassociated with this player.The queue manages both upcoming tracks and playback history. Tracks can be added with
queue.put()/queue.put_wait()and inspected or manipulated via the queue’s public API.- Return type:
Queue
- class sonolink.gateway.player.adapters._nextcord.NextcordPlayer(*args: Any, **kwargs: Any)[source]¶
Bases:
BasePlayer,VoiceProtocolA nextcord implementation of
BasePlayer.This class satisfies the
nextcord.VoiceProtocolcontract expected by nextcord’s voice connection machinery, whilst delegating all Lavalink playback logic to the handlers initialised byBasePlayer.There are two primary ways to create a player:
Class-pass — pass the class itself to
nextcord.abc.Connectable.connect(). nextcord will instantiate it by callingPlayer(client, channel):player = await voice_channel.connect(cls=Player)
Instance-pass — construct a pre-configured instance and pass it instead. nextcord will call
player(client, channel)which hits__call__():player = Player(node=some_node, volume=80) await voice_channel.connect(cls=player)
- Parameters:
node (
Node| None) – The Lavalink node to associate with this player. IfNone, an available node is resolved from the client’s node pool at connection time.queue_mode (
QueueMode) – The initial queue looping mode. Defaults toQueueMode.NORMAL.autoplay_settings (
AutoPlaySettings| None) – AutoPlay configuration.Noneuses the default configuration. History must be enabled when AutoPlay is active.history_settings (
HistorySettings| None) – History configuration.Noneuses the default configuration.volume (
int| None) – Initial volume in the range0–1000. Defaults to100.paused (
bool| None) – Whether the player should start in a paused state. Defaults toFalse.filters (
Filters| None) – Initial audio filters. Defaults to an emptyFiltersinstance.
- guild¶
The guild this player is attached to.
- Type:
- channel¶
The voice channel this player is currently connected to.
- client¶
The nextcord client driving this player.
- Type:
- cleanup() None[source]¶
Cleans the internal state of the Player. This is automatically called by the library when failures or disconnects occur.
If this is overridden, it must call the original
cleanup.
- async connect(*, timeout: float = 10.0, reconnect: bool = False, self_deaf: bool = False, self_mute: bool = False) None¶
Connect this player to its assigned voice channel.
Called automatically by libraries after the player is instantiated. Manual invocation is not normally required.
- Parameters:
timeout (
float) – Seconds to wait for the Discord gateway handshake before raising. Defaults to10.0.reconnect (
bool) – Whether to attempt reconnection on failure. Defaults toFalse.self_deaf (
bool) – Whether to join the channel self-deafened. Defaults toFalse.self_mute (
bool) – Whether to join the channel self-muted. Defaults toFalse.
- async disconnect(*, force: bool = False) None¶
Disconnect this player, destroy it on the Lavalink node, and clean up all internal state.
- Parameters:
force (
bool) – IfTrue, proceeds even if the player is not currently connected. Defaults toFalse.
- get_connection_state() PlayerConnectionState¶
Return a
PlayerConnectionStateinstance for this player.Override this method to supply a custom connection state subclass with additional metadata relevant to your application.
- Return type:
PlayerConnectionState
- async move_to(node: Node, /) None¶
Migrate this player to a different Lavalink node without interrupting playback.
- Parameters:
node (
Node) – The destination node.
- async on_voice_server_update(data: VoiceServerUpdate) None[source]¶
Handle a
VOICE_SERVER_UPDATEpayload from the Discord gateway.Provides the voice server token and endpoint to the Lavalink node so it can establish or re-establish the audio stream.
- Parameters:
data (
nextcord.types.voice.VoiceServerUpdate) – The raw payload received from the Discord gateway.
- async on_voice_state_update(data: GuildVoiceState) None[source]¶
Handle a
VOICE_STATE_UPDATEpayload from the Discord gateway.Provides the session ID and channel ID required for the voice connection handshake with the Lavalink node.
- Parameters:
data (
nextcord.types.voice.GuildVoiceState) – The raw payload received from the Discord gateway.
- async pause() None¶
Set the pause state of the player.
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async play(track: Playable, /, *, start: int = 0, end: int | None = None, volume: int | None = None, paused: bool | None = None) Playable¶
Begin playback of the specified track.
If a track is already playing, it is stopped and the currently playing track is added to history (if history is enabled) before the new track starts.
- Parameters:
track (
Playable) – The track to play.start (
int) – The position in milliseconds at which to begin playback. Defaults to0.end (
int| None) – The position in milliseconds at which to stop playback. IfNone, the track plays to completion. Defaults toNone.volume (
int| None) – Override the player volume for this track only. IfNone, the current player volume is used. Defaults toNone.paused (
bool| None) – IfTrue, the track begins in a paused state. IfNone, the player’s current pause state is preserved. Defaults toNone.
- Returns:
The track that was dispatched to the Lavalink node for playback.
- Return type:
- async previous() Playable¶
Return to the most recently played track in the history.
The current track is pushed back to the front of the queue so it can be reached again via
skip(). The historical track then begins playing immediately.- Returns:
The historical track that is now playing.
- Return type:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
HistoryEmpty – If there is no previous track in the history.
- async resume() None¶
Resume playback if the player is currently paused.
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async seek(position: int, /) None¶
Seek to an arbitrary position within the current track.
- Parameters:
position (
int) – The target position in milliseconds. Must be within the bounds of the current track’s duration.- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async set_filters(filters: Filters, /, *, seek: bool = False) None¶
Apply a new set of audio filters to this player.
- Parameters:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async set_volume(value: int, /) None¶
Set the player’s output volume.
- Parameters:
value (
int) – The desired volume level, in the range0–1000.100is the default (unmodified) level.- Raises:
ValueError – If
valueis outside the range0–1000.RuntimeError – If the player is not connected to a node or an active session.
- async skip() Playable | None¶
Skip the currently playing track and advance to the next one in the queue.
If the queue is empty and AutoPlay is enabled, a related track may be fetched automatically. If neither a queued nor an AutoPlay track is available, playback stops and
Noneis returned.- Returns:
The track that began playing after the skip, or
Noneif the player stopped due to an empty queue with no AutoPlay fallback.- Return type:
Playable| None- Raises:
RuntimeError – If the player is not connected to a node or an active session.
QueueEmpty – If the queue is empty and AutoPlay is disabled or yields no results.
- async stop(*, clear_queue: bool = False, clear_history: bool = False) None¶
Stop the currently playing track.
This sends a stop request to the Lavalink node and resets the player’s internal position tracking and current track reference.
- Parameters:
- Raises:
RuntimeError – If the player is not connected to a node or an active session.
- async update(*, queue_mode: QueueMode | None = None, autoplay_settings: AutoPlaySettings | None = None, history_settings: HistorySettings | None = None, volume: int | None = None, filters: Filters | None = None) None¶
Update the player’s configuration in-place.
Added in version 1.1.0.
- Parameters:
queue_mode (
QueueMode| None) – The new queue looping mode. IfNone, the current mode is preserved.autoplay_settings (
AutoPlaySettings| None) – New AutoPlay configuration. IfNone, the current settings are preserved.history_settings (
HistorySettings| None) – New history configuration. IfNone, the current settings are preserved.volume (
int| None) – New volume in the range0–1000. IfNone, the current volume is preserved.filters (
Filters| None) – New audio filters. IfNone, the current filters are preserved.
- property autoplay: AutoPlayMode¶
The current
AutoPlayModefor this player.When AutoPlay is enabled, the player will automatically fetch and enqueue related tracks when the queue is exhausted.
- Raises:
RuntimeError – When setting, if the player’s history is disabled (history is required for AutoPlay to function).
- property autoplay_settings: AutoPlaySettings¶
The current
AutoPlaySettingsfor this player.Can be mutated directly to update individual fields, or replaced entirely.
Added in version 1.1.0.
- Return type:
- channel: nextcord.abc.Connectable¶
- client: nextcord.Client¶
- property current: Playable | None¶
The track that is currently playing, or
Noneif the player is idle.- Return type:
Playable| None
- property filters: Filters¶
The
Filterscurrently applied to this player.To apply new filters, use
set_filters()rather than mutating this object directly, so that the updated state is dispatched to the Lavalink node.- Return type:
- property guild: Any¶
The guild this player is associated with.
The concrete return type is the guild class of the underlying Discord library (e.g.
discord.Guild,disnake.Guild).- Raises:
RuntimeError – If the player has not yet been attached to a guild.
- property history_settings: HistorySettings¶
The current
HistorySettingsfor this player’s queue.Can be mutated directly to update individual fields, or replaced entirely.
Added in version 1.1.0.
- Return type:
- property node: Node¶
The
Nodethis player is currently attached to.- Raises:
RuntimeError – If the player is not currently attached to a node.
- property position: int¶
The estimated current playback position in milliseconds.
When the player is paused or has not yet started, this returns the last known position. Otherwise, it is calculated by interpolating the time elapsed since the last state update received from the Lavalink node.
- Returns:
Position in milliseconds.
- Return type:
- property queue: Queue¶
The
Queueassociated with this player.The queue manages both upcoming tracks and playback history. Tracks can be added with
queue.put()/queue.put_wait()and inspected or manipulated via the queue’s public API.- Return type:
Queue