PlayerctlPlayer

PlayerctlPlayer — A class to control an MPRIS player

Functions

Properties

GVariant * metadata Read
gchar * player-name Read / Write / Construct Only
gint64 position Read
gchar * status Read
gdouble volume Read / Write

Signals

void exit Run First
void metadata Run First
void pause Run First
void play Run First
void stop Run First

Object Hierarchy

    GObject
    ╰── PlayerctlPlayer

Description

Functions

playerctl_player_new ()

PlayerctlPlayer *
playerctl_player_new (gchar *name,
                      GError **err);

Allocates a new PlayerctlPlayer and tries to connect to the bus name "org.mpris.MediaPlayer2.[name]"

Parameters

name

The name to use to find the bus name of the player.

[allow-none]

err

The location of a GError or NULL

 

Returns

A new PlayerctlPlayer connected to the bus name or NULL if an error occurred.

[transfer full]


playerctl_player_on ()

PlayerctlPlayer *
playerctl_player_on (PlayerctlPlayer *self,
                     const gchar *event,
                     GClosure *callback,
                     GError **err);

A convenience function for bindings to subscribe an event with a callback

Parameters

self

an PlayerctlPlayer

 

event

the event to subscribe to

 

callback

the callback to run on the event

 

Returns

the PlayerctlPlayer for chaining.

[transfer none]


playerctl_player_play_pause ()

PlayerctlPlayer *
playerctl_player_play_pause (PlayerctlPlayer *self,
                             GError **err);

Command the player to play if it is playing or pause if it is paused

Parameters

self

a PlayerctlPlayer

 

err (allow-none)

the location of a GError or NULL

 

Returns

the PlayerctlPlayer for chaining.

[transfer none]


playerctl_player_play ()

PlayerctlPlayer *
playerctl_player_play (PlayerctlPlayer *self,
                       GError **err);

Command the player to play

Parameters

self

a PlayerctlPlayer

 

err (allow-none)

the location of a GError or NULL

 

Returns

the PlayerctlPlayer for chaining.

[transfer none]


playerctl_player_stop ()

PlayerctlPlayer *
playerctl_player_stop (PlayerctlPlayer *self,
                       GError **err);

Command the player to stop

Parameters

self

a PlayerctlPlayer

 

err (allow-none)

the location of a GError or NULL

 

Returns

the PlayerctlPlayer for chaining.

[transfer none]


playerctl_player_seek ()

PlayerctlPlayer *
playerctl_player_seek (PlayerctlPlayer *self,
                       gint64 offset,
                       GError **err);

Command the player to seek

Parameters

self

a PlayerctlPlayer

 

err (allow-none)

the location of a GError or NULL

 

Returns

the PlayerctlPlayer for chaining.

[transfer none]


playerctl_player_pause ()

PlayerctlPlayer *
playerctl_player_pause (PlayerctlPlayer *self,
                        GError **err);

Command the player to pause

Parameters

self

a PlayerctlPlayer

 

err (allow-none)

the location of a GError or NULL

 

Returns

the PlayerctlPlayer for chaining.

[transfer none]


playerctl_player_next ()

PlayerctlPlayer *
playerctl_player_next (PlayerctlPlayer *self,
                       GError **err);

Command the player to go to the next track

Parameters

self

a PlayerctlPlayer

 

err

the location of a GError or NULL.

[allow-none]

Returns

the PlayerctlPlayer for chaining.

[transfer none]


playerctl_player_previous ()

PlayerctlPlayer *
playerctl_player_previous (PlayerctlPlayer *self,
                           GError **err);

Command the player to go to the previous track

Parameters

self

a PlayerctlPlayer

 

err

the location of a GError or NULL.

[allow-none]

Returns

the PlayerctlPlayer for chaining.

[transfer none]


playerctl_player_print_metadata_prop ()

gchar *
playerctl_player_print_metadata_prop (PlayerctlPlayer *self,
                                      gchar *property,
                                      GError **err);

Gets the artist from the metadata of the current track, or empty string if no track is playing.

Parameters

self

a PlayerctlPlayer

 

property

the property from the metadata to print.

[allow-none]

err

the location of a GError or NULL.

[allow-none]

Returns

The artist from the metadata of the current track.

[transfer full]


playerctl_player_get_artist ()

gchar *
playerctl_player_get_artist (PlayerctlPlayer *self,
                             GError **err);

Gets the artist from the metadata of the current track, or empty string if no track is playing.

Parameters

self

a PlayerctlPlayer

 

err

the location of a GError or NULL.

[allow-none]

Returns

The artist from the metadata of the current track.

[transfer full]


playerctl_player_get_title ()

gchar *
playerctl_player_get_title (PlayerctlPlayer *self,
                            GError **err);

Gets the title from the metadata of the current track, or empty string if no track is playing.

Parameters

self

a PlayerctlPlayer

 

err

the location of a GError or NULL.

[allow-none]

Returns

The title from the metadata of the current track.

[transfer full]


playerctl_player_get_album ()

gchar *
playerctl_player_get_album (PlayerctlPlayer *self,
                            GError **err);

Gets the album from the metadata of the current track, or empty string if no track is playing.

Parameters

self

a PlayerctlPlayer

 

err

the location of a GError or NULL.

[allow-none]

Returns

The album from the metadata of the current track.

[transfer full]


playerctl_player_set_position ()

void
playerctl_player_set_position (PlayerctlPlayer *self,
                               gint64 position,
                               GError **err);

Sets the position of the current track to the given position in microseconds.

Parameters

self

a PlayerctlPlayer

 

err

the location of a GError or NULL.

[allow-none]

Types and Values

Property Details

The “metadata” property

  “metadata”                 GVariant *

The metadata of the currently playing track.

Flags: Read

Allowed values: GVariant<v>

Default value: NULL


The “player-name” property

  “player-name”              gchar *

The name of the player mpris player.

Flags: Read / Write / Construct Only

Default value: NULL


The “position” property

  “position”                 gint64

The position in the current track of the player.

Flags: Read

Allowed values: >= 0

Default value: 0


The “status” property

  “status”                   gchar *

The play status of the player.

Flags: Read

Default value: NULL


The “volume” property

  “volume”                   gdouble

The volume level of the player.

Flags: Read / Write

Allowed values: [0,100]

Default value: 0

Signal Details

The “exit” signal

void
user_function (PlayerctlPlayer *playerctlplayer,
               gpointer         user_data)

Flags: Run First


The “metadata” signal

void
user_function (PlayerctlPlayer *playerctlplayer,
               GVariant        *arg1,
               gpointer         user_data)

Flags: Run First


The “pause” signal

void
user_function (PlayerctlPlayer *playerctlplayer,
               gpointer         user_data)

Flags: Run First


The “play” signal

void
user_function (PlayerctlPlayer *playerctlplayer,
               gpointer         user_data)

Flags: Run First


The “stop” signal

void
user_function (PlayerctlPlayer *playerctlplayer,
               gpointer         user_data)

Flags: Run First