Player¶
Allows for playback and queue control
-
xl.player.
PLAYER
= <xl.player.player.ExailePlayer object>¶ This is the player object that everything in Exaile interacts with to control audio playback. The player object controls a playback engine, which actually controls audio playback. Nothing in this object should be specific to a particular engine. Examples of engines could be GStreamer, Xine, etc. Currently only the GStreamer engine is actually implemented.
All public functions are assumed to be called from the Glib main thread, or bad things will happen. This includes most engine functions, with one or two noted exceptions.
The player singleton of ExailePlayer
for playback control
ExailePlayer.
play
(track, start_at=None, paused=False)[source]¶Starts the playback with the provided track or stops the playback it immediately if none
Parameters:
- track (
xl.trax.Track
) – the track to play or None- start_at – The offset to start playback at, in seconds
- paused – If True, start the track in ‘paused’ mode
Note
The following events will be emitted by this method:
- playback_player_start: indicates the start of playback overall
- playback_track_start: indicates playback start of a track
ExailePlayer.
stop
()[source]¶Stops the playback
Note
The following events will be emitted by this method:
- playback_player_end: indicates the end of playback overall
- playback_track_end: indicates playback end of a track
ExailePlayer.
pause
()[source]¶Pauses the playback if playing, does not toggle it
Returns: True if paused, False otherwise Note
The following events will be emitted by this method:
- playback_player_pause: indicates that the playback has been paused
- playback_toggle_pause: indicates that the playback has been paused or resumed
ExailePlayer.
unpause
()[source]¶Resumes the playback if it is paused, does not toggle it
Returns: True if paused, False otherwise Note
The following events will be emitted by this method:
- playback_player_resume: indicates that the playback has been resumed
- playback_toggle_pause: indicates that the playback has been paused or resumed
ExailePlayer.
toggle_pause
()[source]¶Toggles between playing and paused state. Only valid when playback is not stopped.
Returns: True if toggled, false otherwise Note
The following events will be emitted by this method:
- playback_toggle_pause: indicates that the playback has been paused or resumed
ExailePlayer.
seek
(value)[source]¶Seek to a position in the currently playing stream
Parameters: value (int) – the position in seconds
ExailePlayer.
get_position
()[source]¶Gets the current playback position of the playing track
Returns: the playback position in nanoseconds Return type: int
ExailePlayer.
get_time
()[source]¶Gets the current playback time
Returns: the playback time in seconds Return type: float
ExailePlayer.
get_progress
() → float[source]¶Gets the current playback progress
Returns: the playback progress as [0..1]
ExailePlayer.
set_progress
(progress)[source]¶Seeks to the progress position
Parameters: progress (float) – value ranged at [0..1]
ExailePlayer.
get_volume
()[source]¶Gets the current user volume
Returns: the volume percentage Type: int
ExailePlayer.
set_volume
(volume)[source]¶Sets the current user volume
Parameters: volume (int) – the volume percentage
ExailePlayer.
modify_volume
(diff)[source]¶Changes the current user volume
Parameters: diff – the volume difference (pos or neg) percentage units
ExailePlayer.
get_state
()[source]¶Gets the player state
Returns: one of playing, paused or stopped Return type: string
ExailePlayer.
is_playing
()[source]¶Convenience method to find out if the player is currently playing
Returns: whether the player is currently playing Return type: bool
-
xl.player.
QUEUE
= <xl.player.queue.PlayQueue object>¶ Manages the queue of songs to be played
The content of the queue are processed before processing the content of the assigned playlist.
When the remove_item_when_played option is enabled, the queue removes items from itself as they are played.
When not enabled, the queue acts like a regular playlist, and moves the position as tracks are played.
In this mode, when a new track is queued, the position is set to play that track, and play will continue with that track until the queue is exhausted, and then the assigned playlist will be continued.
TODO: Queue needs to be threadsafe!
The queue singleton of PlayQueue
- class
xl.player.queue.
PlayQueue
(player, name, location=None)[source]¶Bases:
xl.playlist.Playlist
Manages the queue of songs to be played
The content of the queue are processed before processing the content of the assigned playlist.
When the remove_item_when_played option is enabled, the queue removes items from itself as they are played.
When not enabled, the queue acts like a regular playlist, and moves the position as tracks are played.
In this mode, when a new track is queued, the position is set to play that track, and play will continue with that track until the queue is exhausted, and then the assigned playlist will be continued.
TODO: Queue needs to be threadsafe!
current_playlist
¶The playlist currently processed in the queue
get_current
()[source]¶Gets the current track
Returns: the current track Type: xl.trax.Track
get_next
()[source]¶Retrieves the next track that will be played. Does not actually set the position. When you call next(), it should return the same track.
This exists to support retrieving a track before it actually needs to be played, such as for pre-buffering.
Returns: the next track to be played Return type: xl.trax.Track
or None
next
(autoplay=True, track=None)[source]¶Goes to the next track, either in the queue, or in the current playlist. If a track is passed in, that track is played
Parameters:
- autoplay (bool) – play the track in addition to returning it
- track (
xl.trax.Track
) – if passed, play this trackNote
The following events will be emitted by this method:
- playback_playlist_end: indicates that the end of the queue has been reached
play
(track=None)[source]¶Starts queue processing with the given track preceding the queue content
Parameters: track ( xl.trax.Track
) – the track to play
set_current_playlist
(playlist)[source]¶Sets the playlist to be processed in the queue
Parameters: playlist ( xl.playlist.Playlist
) – the playlist to processNote
The following events will be emitted by this method:
- queue_current_playlist_changed: indicates that the queue playlist has been changed