Playerctl.Player¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r |
Whether the player can be controlled by playerctl |
||
r |
Whether the player can go to the next track |
||
r |
Whether the player can go to the previous track |
||
r |
Whether the player can pause |
||
r |
Whether the player can start playing and has a current track. |
||
r |
Whether the position of the player can be controlled |
||
r |
The loop status of the player |
||
r |
The metadata of the currently playing track as an array of key-value pairs. The metadata available depends on the track, but may include the artist, title, length, art url, and other metadata. |
||
r |
Whether the player is playing, paused, or stopped |
||
r/w/co |
An instance name that identifies this player on the source |
||
r/w/co |
The name of the type of player this is. The instance is fully qualified with the player-instance and the source. |
||
r |
The position in the current track of the player in microseconds |
||
r |
A value of false indicates that playback is progressing linearly through a playlist, while true means playback is progressing through a playlist in some other order. |
||
r/w/co |
The source of this player. Currently supported sources are the DBus session bus and DBus system bus. |
||
d/r |
The play status of the player (deprecated: use playback-status) |
||
r/w |
The volume level of the player. Setting this property directly is deprecated and this property will become read only in a future version. Use |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted when the player has disconnected and will no longer respond to queries and commands. |
|
Emitted when the loop status changes. |
|
Emitted when the metadata for the currently playing track changes. |
|
Emitted when the player pauses. |
|
Emitted when the player begins to play. |
|
Emitted when the playback status changes. |
|
Emitted when the track changes position unexpectedly or begins in a position other than the beginning. |
|
Emitted when the shuffle status changes. |
|
Emitted when the player stops. |
|
Emitted when the volume of the player changes. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Playerctl.Player(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
- classmethod new(player_name)¶
- Parameters:
player_name (
str
orNone
) – The name to use to find the bus name of the player- Raises:
- Returns:
A new
Playerctl.Player
connected to an instance of the player orNone
if an error occurred- Return type:
Allocates a new
Playerctl.Player
and tries to connect to an instance of the player with the given name.
- classmethod new_for_source(player_name, source)¶
- Parameters:
player_name (
str
orNone
) – The name to use to find the bus name of the playersource (
Playerctl.Source
) – The source where the player name is.
- Raises:
- Returns:
A new
Playerctl.Player
connected to an instance of the player orNone
if an error occurred- Return type:
Allocates a new
Playerctl.Player
and tries to connect to an instance of the player with the given name from the given source.
- classmethod new_from_name(player_name)¶
- Parameters:
player_name (
Playerctl.PlayerName
) – The name type to use to find the player- Raises:
- Returns:
A new
Playerctl.Player
connected to the player orNone
if an error occurred- Return type:
Allocates a new
Playerctl.Player
and tries to connect to the player identified by thePlayerctl.PlayerName
.
- get_album()¶
- Raises:
- Returns:
The album from the metadata of the current track
- Return type:
Gets the album from the metadata of the current track, or
None
if no track is playing.
- get_artist()¶
- Raises:
- Returns:
The artist from the metadata of the current track
- Return type:
Gets the artist from the metadata of the current track, or
None
if no track is playing.
- get_position()¶
- Raises:
- Return type:
Gets the position of the current track in microseconds ignoring the property cache.
- get_title()¶
- Raises:
- Returns:
The title from the metadata of the current track
- Return type:
Gets the title from the metadata of the current track, or
None
if no track is playing.
- next()¶
- Raises:
Command the player to go to the next track
- on(event, callback)¶
- Parameters:
event (
str
) – the event to subscribe tocallback (
GObject.Closure
) – the callback to run on the event
- Raises:
A convenience function for bindings to subscribe to an event with a callback
Deprecated since version 2.0.0: Use
GObject.Object.connect
() to listen to events.
- open(uri)¶
- Parameters:
uri (
str
) – the URI to open, either a file name or an external URL- Raises:
Command the player to open given URI
- pause()¶
- Raises:
Command the player to pause
- play()¶
- Raises:
Command the player to play
- play_pause()¶
- Raises:
Command the player to play if it is paused or pause if it is playing
- previous()¶
- Raises:
Command the player to go to the previous track
- print_metadata_prop(property)¶
- Parameters:
property (
str
orNone
) – the property from the metadata to print- Raises:
- Returns:
The artist from the metadata of the current track
- Return type:
Gets the given property from the metadata of the current track. If property is null, prints all the metadata properties. Returns
None
if no track is playing.
- seek(offset)¶
- Parameters:
offset (
int
) – the offset to seek forward to in microseconds- Raises:
Command the player to seek forward by offset given in microseconds.
- set_loop_status(status)¶
- Parameters:
status (
Playerctl.LoopStatus
) – the requestedPlayerctl.LoopStatus
to set the player to- Raises:
Set the loop status of the player. Can be set to either None, Track, or Playlist.
- set_position(position)¶
- Parameters:
position (
int
) – The absolute position in the track to set as the position- Raises:
Sets the absolute position of the current track to the given position in microseconds.
- set_shuffle(shuffle)¶
- Parameters:
shuffle (
bool
) – whether to enable shuffle- Raises:
Request to set the shuffle state of the player, either on or off.
- set_volume(volume)¶
- Parameters:
volume (
float
) – the volume level from 0.0 to 1.0- Raises:
Sets the volume level for the player from 0.0 for no volume to 1.0 for maximum volume. Passing negative numbers should set the volume to 0.0.
- stop()¶
- Raises:
Command the player to stop
Signal Details¶
- Playerctl.Player.signals.exit(player)¶
- Signal Name:
exit
- Flags:
- Parameters:
player (
Playerctl.Player
) – The object which received the signal
Emitted when the player has disconnected and will no longer respond to queries and commands.
- Playerctl.Player.signals.loop_status(player, loop_status)¶
- Signal Name:
loop-status
- Flags:
- Parameters:
player (
Playerctl.Player
) – The object which received the signalloop_status (
Playerctl.LoopStatus
) – the loop status of the player
Emitted when the loop status changes.
- Playerctl.Player.signals.metadata(player, metadata)¶
- Signal Name:
metadata
- Flags:
- Parameters:
player (
Playerctl.Player
) – The object which received the signalmetadata (
GLib.Variant
) – the metadata for the currently playing track.
Emitted when the metadata for the currently playing track changes.
- Playerctl.Player.signals.pause(player)¶
- Signal Name:
pause
- Flags:
- Parameters:
player (
Playerctl.Player
) – The object which received the signal
Emitted when the player pauses.
Deprecated since version 2.0.0: Use the “playback-status::paused” signal instead.
- Playerctl.Player.signals.play(player)¶
- Signal Name:
play
- Flags:
- Parameters:
player (
Playerctl.Player
) – The object which received the signal
Emitted when the player begins to play.
Deprecated since version 2.0.0: Use the “playback-status::playing” signal instead.
- Playerctl.Player.signals.playback_status(player, playback_status)¶
- Signal Name:
playback-status
- Flags:
- Parameters:
player (
Playerctl.Player
) – The object which received the signalplayback_status (
Playerctl.PlaybackStatus
) – the playback status of the player
Emitted when the playback status changes. Detail will be “playing”, “paused”, or “stopped” which you can listen to by connecting to the “playback-status::[STATUS]” signal.
- Playerctl.Player.signals.seeked(player, position)¶
- Signal Name:
seeked
- Flags:
- Parameters:
player (
Playerctl.Player
) – The object which received the signalposition (
int
) – the new position in the track in microseconds.
Emitted when the track changes position unexpectedly or begins in a position other than the beginning. Otherwise, position is assumed to progress normally.
- Playerctl.Player.signals.shuffle(player, shuffle_status)¶
- Signal Name:
shuffle
- Flags:
- Parameters:
player (
Playerctl.Player
) – The object which received the signalshuffle_status (
bool
) – the shuffle status of the player
Emitted when the shuffle status changes.
- Playerctl.Player.signals.stop(player)¶
- Signal Name:
stop
- Flags:
- Parameters:
player (
Playerctl.Player
) – The object which received the signal
Emitted when the player stops.
Deprecated since version 2.0.0: Use the “playback-status::stopped” signal instead.
- Playerctl.Player.signals.volume(player, volume)¶
- Signal Name:
volume
- Flags:
- Parameters:
player (
Playerctl.Player
) – The object which received the signalvolume (
float
) – the volume of the player from 0 to 100.
Emitted when the volume of the player changes.
Property Details¶
- Playerctl.Player.props.can_control¶
-
Whether the player can be controlled by playerctl
- Playerctl.Player.props.can_go_next¶
-
Whether the player can go to the next track
- Playerctl.Player.props.can_go_previous¶
-
Whether the player can go to the previous track
- Playerctl.Player.props.can_pause¶
-
Whether the player can pause
- Playerctl.Player.props.can_play¶
-
Whether the player can start playing and has a current track.
- Playerctl.Player.props.can_seek¶
-
Whether the position of the player can be controlled
- Playerctl.Player.props.loop_status¶
- Name:
loop-status
- Type:
- Default Value:
- Flags:
The loop status of the player
- Playerctl.Player.props.metadata¶
- Name:
metadata
- Type:
- Default Value:
- Flags:
The metadata of the currently playing track as an array of key-value pairs. The metadata available depends on the track, but may include the artist, title, length, art url, and other metadata.
- Playerctl.Player.props.playback_status¶
- Name:
playback-status
- Type:
- Default Value:
- Flags:
Whether the player is playing, paused, or stopped
- Playerctl.Player.props.player_instance¶
- Name:
player-instance
- Type:
- Default Value:
- Flags:
An instance name that identifies this player on the source
- Playerctl.Player.props.player_name¶
- Name:
player-name
- Type:
- Default Value:
- Flags:
The name of the type of player this is. The instance is fully qualified with the player-instance and the source.
- Playerctl.Player.props.position¶
-
The position in the current track of the player in microseconds
- Playerctl.Player.props.shuffle¶
-
A value of false indicates that playback is progressing linearly through a playlist, while true means playback is progressing through a playlist in some other order.
- Playerctl.Player.props.source¶
- Name:
source
- Type:
- Default Value:
- Flags:
The source of this player. Currently supported sources are the DBus session bus and DBus system bus.
- Playerctl.Player.props.status¶
- Name:
status
- Type:
- Default Value:
- Flags:
The playback status of the player as a string
Deprecated since version 2.0.0: Use the “playback-status” signal instead.
- Playerctl.Player.props.volume¶
-
The volume level of the player. Setting this property directly is deprecated and this property will become read only in a future version. Use
Playerctl.Player.set_volume
() to set the volume.