MPD: playlist Struct Reference

MPD 0.20.18

Public Member Functions | Data Fields | Protected Member Functions
playlist Struct Reference

`#include <Playlist.hxx>`

Collaboration diagram for playlist:
[legend]

## Public Member Functions
| playlist (unsigned max_length, QueueListener &_listener)
| ~playlist ()
uint32_t | GetVersion () const
unsigned | GetLength () const
unsigned | PositionToId (unsigned position) const
gcc_pure int | GetCurrentPosition () const noexcept
gcc_pure int | GetNextPosition () const noexcept
gcc_pure const DetachedSong * | GetQueuedSong () const noexcept
| Returns the song object which is currently queued. More...
void | SyncWithPlayer (PlayerControl &pc)
| This is the "PLAYLIST" event handler. More...
void | BeginBulk ()
void | CommitBulk (PlayerControl &pc)
void | Clear (PlayerControl &pc)
void | TagModified (DetachedSong &&song)
| A tag in the play queue has been modified by the player thread. More...
unsigned | AppendSong (PlayerControl &pc, DetachedSong &&song)
| Throws PlaylistError if the queue would be too large. More...
unsigned | AppendURI (PlayerControl &pc, const SongLoader &loader, const char *uri_utf8)
| Throws #std::runtime_error on error. More...
void | DeletePosition (PlayerControl &pc, unsigned position)
void | DeleteOrder (PlayerControl &pc, unsigned order)
void | DeleteId (PlayerControl &pc, unsigned id)
void | DeleteRange (PlayerControl &pc, unsigned start, unsigned end)
| Deletes a range of songs from the playlist. More...
void | StaleSong (PlayerControl &pc, const char *uri)
| Mark the given song as "stale", i.e. More...
void | Shuffle (PlayerControl &pc, unsigned start, unsigned end)
void | MoveRange (PlayerControl &pc, unsigned start, unsigned end, int to)
void | MoveId (PlayerControl &pc, unsigned id, int to)
void | SwapPositions (PlayerControl &pc, unsigned song1, unsigned song2)
void | SwapIds (PlayerControl &pc, unsigned id1, unsigned id2)
void | SetPriorityRange (PlayerControl &pc, unsigned start_position, unsigned end_position, uint8_t priority)
void | SetPriorityId (PlayerControl &pc, unsigned song_id, uint8_t priority)
void | SetSongIdRange (PlayerControl &pc, unsigned id, SongTime start, SongTime end)
| Sets the start_time and end_time attributes on the song with the specified id. More...
void | AddSongIdTag (unsigned id, TagType tag_type, const char *value)
void | ClearSongIdTag (unsigned id, TagType tag_type)
void | Stop (PlayerControl &pc)
void | PlayPosition (PlayerControl &pc, int position)
| Throws std::runtime_error or #Error on error. More...
void | PlayOrder (PlayerControl &pc, unsigned order)
| Throws std::runtime_error or #Error on error. More...
void | PlayId (PlayerControl &pc, int id)
| Throws std::runtime_error or #Error on error. More...
void | PlayNext (PlayerControl &pc)
| Throws std::runtime_error or #Error on error. More...
void | PlayPrevious (PlayerControl &pc)
| Throws std::runtime_error or #Error on error. More...
void | SeekSongOrder (PlayerControl &pc, unsigned song_order, SongTime seek_time)
| Throws std::runtime_error or #Error on error. More...
void | SeekSongPosition (PlayerControl &pc, unsigned sonag_position, SongTime seek_time)
| Throws std::runtime_error or #Error on error. More...
void | SeekSongId (PlayerControl &pc, unsigned song_id, SongTime seek_time)
| Throws std::runtime_error or #Error on error. More...
void | SeekCurrent (PlayerControl &pc, SignedSongTime seek_time, bool relative)
| Seek within the current song. More...
bool | GetRepeat () const
void | SetRepeat (PlayerControl &pc, bool new_value)
bool | GetRandom () const
void | SetRandom (PlayerControl &pc, bool new_value)
bool | GetSingle () const
void | SetSingle (PlayerControl &pc, bool new_value)
bool | GetConsume () const
void | SetConsume (bool new_value)

## Data Fields
Queue | queue
| The song queue - it contains the "real" playlist. More...
QueueListener & | listener
bool | playing
| This value is true if the player is currently playing (or should be playing). More...
bool | stop_on_error
| If true, then any error is fatal; if false, MPD will attempt to play the next song on non-fatal errors. More...
bool | bulk_edit
| If true, then a bulk edit has been initiated by BeginBulk(), and UpdateQueuedSong() and OnModified() will be postponed until CommitBulk() More...
bool | bulk_modified
| Has the queue been modified during bulk edit mode? More...
unsigned | error_count
| Number of errors since playback was started. More...
int | current
| The "current song pointer" (the order number). More...
int | queued
| The "next" song to be played (the order number), when the current one finishes. More...

## Protected Member Functions
void | OnModified ()
| Called by all editing methods after a modification. More...
void | SongStarted ()
| Called when playback of a new song starts. More...
void | UpdateQueuedSong (PlayerControl &pc, const DetachedSong *prev)
| Updates the "queued song". More...
void | QueueSongOrder (PlayerControl &pc, unsigned order)
| Queue a song, addressed by its order number. More...
void | QueuedSongStarted (PlayerControl &pc)
| Called when the player thread has started playing the "queued" song, i.e. More...
void | ResumePlayback (PlayerControl &pc)
| The player has stopped for some reason. More...
void | DeleteInternal (PlayerControl &pc, unsigned song, const DetachedSong **queued_p)

## Detailed Description

Definition at line 34 of file Playlist.hxx.

## Constructor & Destructor Documentation

## ◆ playlist()

playlist::playlist | ( | unsigned | max_length,
|  | QueueListener & | _listener
| ) |  |
| inline

Definition at line 91 of file Playlist.hxx.

## ◆ ~playlist()

playlist::~playlist | ( |  | ) |
| inline

Definition at line 100 of file Playlist.hxx.

## Member Function Documentation

## ◆ AddSongIdTag()

void playlist::AddSongIdTag | ( | unsigned | id,
|  | TagType | tag_type,
|  | const char * | value
| ) |  |

## ◆ AppendSong()

unsigned playlist::AppendSong | ( | PlayerControl & | pc,
|  | DetachedSong && | song
| ) |  |

Throws PlaylistError if the queue would be too large.

Returns
  the new song id

## ◆ AppendURI()

unsigned playlist::AppendURI | ( | PlayerControl & | pc,
|  | const SongLoader & | loader,
|  | const char * | uri_utf8
| ) |  |

Throws #std::runtime_error on error.

Returns
  the new song id

## ◆ BeginBulk()

void playlist::BeginBulk | ( |  | ) |

## ◆ Clear()

void playlist::Clear | ( | PlayerControl & | pc | ) |

## ◆ ClearSongIdTag()

void playlist::ClearSongIdTag | ( | unsigned | id,
|  | TagType | tag_type
| ) |  |

## ◆ CommitBulk()

void playlist::CommitBulk | ( | PlayerControl & | pc | ) |

## ◆ DeleteId()

void playlist::DeleteId | ( | PlayerControl & | pc,
|  | unsigned | id
| ) |  |

## ◆ DeleteInternal()

void playlist::DeleteInternal | ( | PlayerControl & | pc,
|  | unsigned | song,
|  | const DetachedSong ** | queued_p
| ) |  |
| protected

## ◆ DeleteOrder()

void playlist::DeleteOrder | ( | PlayerControl & | pc,
|  | unsigned | order
| ) |  |
| inline

Definition at line 226 of file Playlist.hxx.

## ◆ DeletePosition()

void playlist::DeletePosition | ( | PlayerControl & | pc,
|  | unsigned | position
| ) |  |

## ◆ DeleteRange()

void playlist::DeleteRange | ( | PlayerControl & | pc,
|  | unsigned | start,
|  | unsigned | end
| ) |  |

Deletes a range of songs from the playlist.

Parameters

  start | the position of the first song to delete
  end | the position after the last song to delete

## ◆ GetConsume()

bool playlist::GetConsume | ( |  | ) | const
| inline

Definition at line 354 of file Playlist.hxx.

## ◆ GetCurrentPosition()

gcc_pure int playlist::GetCurrentPosition | ( |  | ) | const
| noexcept

## ◆ GetLength()

unsigned playlist::GetLength | ( |  | ) | const
| inline

Definition at line 107 of file Playlist.hxx.

## ◆ GetNextPosition()

gcc_pure int playlist::GetNextPosition | ( |  | ) | const
| noexcept

## ◆ GetQueuedSong()

gcc_pure const DetachedSong* playlist::GetQueuedSong | ( |  | ) | const
| noexcept

Returns the song object which is currently queued.

Returns none if there is none (yet?) or if MPD isn't playing.

## ◆ GetRandom()

bool playlist::GetRandom | ( |  | ) | const
| inline

Definition at line 342 of file Playlist.hxx.

## ◆ GetRepeat()

bool playlist::GetRepeat | ( |  | ) | const
| inline

Definition at line 336 of file Playlist.hxx.

## ◆ GetSingle()

bool playlist::GetSingle | ( |  | ) | const
| inline

Definition at line 348 of file Playlist.hxx.

## ◆ GetVersion()

uint32_t playlist::GetVersion | ( |  | ) | const
| inline

Definition at line 103 of file Playlist.hxx.

## ◆ MoveId()

void playlist::MoveId | ( | PlayerControl & | pc,
|  | unsigned | id,
|  | int | to
| ) |  |

## ◆ MoveRange()

void playlist::MoveRange | ( | PlayerControl & | pc,
|  | unsigned | start,
|  | unsigned | end,
|  | int | to
| ) |  |

## ◆ OnModified()

void playlist::OnModified | ( |  | ) |
| protected

Called by all editing methods after a modification.

Updates the queue version and invokes QueueListener::OnQueueModified().

## ◆ PlayId()

void playlist::PlayId | ( | PlayerControl & | pc,
|  | int | id
| ) |  |

Throws std::runtime_error or #Error on error.

## ◆ PlayNext()

void playlist::PlayNext | ( | PlayerControl & | pc | ) |

Throws std::runtime_error or #Error on error.

## ◆ PlayOrder()

void playlist::PlayOrder | ( | PlayerControl & | pc,
|  | unsigned | order
| ) |  |

Throws std::runtime_error or #Error on error.

## ◆ PlayPosition()

void playlist::PlayPosition | ( | PlayerControl & | pc,
|  | int | position
| ) |  |

Throws std::runtime_error or #Error on error.

## ◆ PlayPrevious()

void playlist::PlayPrevious | ( | PlayerControl & | pc | ) |

Throws std::runtime_error or #Error on error.

## ◆ PositionToId()

unsigned playlist::PositionToId | ( | unsigned | position | ) | const
| inline

Definition at line 111 of file Playlist.hxx.

## ◆ QueuedSongStarted()

void playlist::QueuedSongStarted | ( | PlayerControl & | pc | ) |
| protected

Called when the player thread has started playing the "queued" song, i.e.

it has switched from one song to the next automatically.

## ◆ QueueSongOrder()

void playlist::QueueSongOrder | ( | PlayerControl & | pc,
|  | unsigned | order
| ) |  |
| protected

Queue a song, addressed by its order number.

## ◆ ResumePlayback()

void playlist::ResumePlayback | ( | PlayerControl & | pc | ) |
| protected

The player has stopped for some reason.

Check the error, and decide whether to re-start playback.

## ◆ SeekCurrent()

void playlist::SeekCurrent | ( | PlayerControl & | pc,
|  | SignedSongTime | seek_time,
|  | bool | relative
| ) |  |

Seek within the current song.

Fails if MPD is not currently playing.

Throws std::runtime_error or #Error on error.

Parameters

  seek_time | the time
  relative | if true, then the specified time is relative to the current position

## ◆ SeekSongId()

void playlist::SeekSongId | ( | PlayerControl & | pc,
|  | unsigned | song_id,
|  | SongTime | seek_time
| ) |  |

Throws std::runtime_error or #Error on error.

## ◆ SeekSongOrder()

void playlist::SeekSongOrder | ( | PlayerControl & | pc,
|  | unsigned | song_order,
|  | SongTime | seek_time
| ) |  |

Throws std::runtime_error or #Error on error.

## ◆ SeekSongPosition()

void playlist::SeekSongPosition | ( | PlayerControl & | pc,
|  | unsigned | sonag_position,
|  | SongTime | seek_time
| ) |  |

Throws std::runtime_error or #Error on error.

## ◆ SetConsume()

void playlist::SetConsume | ( | bool | new_value | ) |

## ◆ SetPriorityId()

void playlist::SetPriorityId | ( | PlayerControl & | pc,
|  | unsigned | song_id,
|  | uint8_t | priority
| ) |  |

## ◆ SetPriorityRange()

void playlist::SetPriorityRange | ( | PlayerControl & | pc,
|  | unsigned | start_position,
|  | unsigned | end_position,
|  | uint8_t | priority
| ) |  |

## ◆ SetRandom()

void playlist::SetRandom | ( | PlayerControl & | pc,
|  | bool | new_value
| ) |  |

## ◆ SetRepeat()

void playlist::SetRepeat | ( | PlayerControl & | pc,
|  | bool | new_value
| ) |  |

## ◆ SetSingle()

void playlist::SetSingle | ( | PlayerControl & | pc,
|  | bool | new_value
| ) |  |

## ◆ SetSongIdRange()

void playlist::SetSongIdRange | ( | PlayerControl & | pc,
|  | unsigned | id,
|  | SongTime | start,
|  | SongTime | end
| ) |  |

Sets the start_time and end_time attributes on the song with the specified id.

## ◆ Shuffle()

void playlist::Shuffle | ( | PlayerControl & | pc,
|  | unsigned | start,
|  | unsigned | end
| ) |  |

## ◆ SongStarted()

void playlist::SongStarted | ( |  | ) |
| protected

Called when playback of a new song starts.

Unlike QueuedSongStarted(), this also gets called when the user manually switches to another song. It may be used for playlist fixups.

The song being started is specified by the current attribute.

## ◆ StaleSong()

void playlist::StaleSong | ( | PlayerControl & | pc,
|  | const char * | uri
| ) |  |

Mark the given song as "stale", i.e.

as not being available anymore. This gets called when a song is removed from the database. The method attempts to remove all instances of this song from the queue.

## ◆ Stop()

void playlist::Stop | ( | PlayerControl & | pc | ) |

## ◆ SwapIds()

void playlist::SwapIds | ( | PlayerControl & | pc,
|  | unsigned | id1,
|  | unsigned | id2
| ) |  |

## ◆ SwapPositions()

void playlist::SwapPositions | ( | PlayerControl & | pc,
|  | unsigned | song1,
|  | unsigned | song2
| ) |  |

## ◆ SyncWithPlayer()

void playlist::SyncWithPlayer | ( | PlayerControl & | pc | ) |

This is the "PLAYLIST" event handler.

It is invoked by the player thread whenever it requests a new queued song, or when it exits.

## ◆ TagModified()

void playlist::TagModified | ( | DetachedSong && | song | ) |

A tag in the play queue has been modified by the player thread.

Apply the given song's tag to the current song if the song matches.

## ◆ UpdateQueuedSong()

void playlist::UpdateQueuedSong | ( | PlayerControl & | pc,
|  | const DetachedSong * | prev
| ) |  |
| protected

Updates the "queued song".

Calculates the next song according to the current one (if MPD isn't playing, it takes the first song), and queues this song. Clears the old queued song if there was one.

Parameters

  prev | the song which was previously queued, as determined by playlist_get_queued_song()

## Field Documentation

## ◆ bulk_edit

bool playlist::bulk_edit

If true, then a bulk edit has been initiated by BeginBulk(), and UpdateQueuedSong() and OnModified() will be postponed until CommitBulk()

Definition at line 60 of file Playlist.hxx.

## ◆ bulk_modified

bool playlist::bulk_modified

Has the queue been modified during bulk edit mode?

Definition at line 65 of file Playlist.hxx.

## ◆ current

int playlist::current

The "current song pointer" (the order number).

This is the song which is played when we get the "play" command. It is also the song which is currently being played.

Definition at line 79 of file Playlist.hxx.

## ◆ error_count

unsigned playlist::error_count

Number of errors since playback was started.

If this number exceeds the length of the playlist, MPD gives up, because all songs have been tried.

Definition at line 72 of file Playlist.hxx.

## ◆ listener

QueueListener& playlist::listener

Definition at line 40 of file Playlist.hxx.

## ◆ playing

bool playlist::playing

This value is true if the player is currently playing (or should be playing).

Definition at line 46 of file Playlist.hxx.

## ◆ queue

Queue playlist::queue

The song queue - it contains the "real" playlist.

Definition at line 38 of file Playlist.hxx.

## ◆ queued

int playlist::queued

The "next" song to be played (the order number), when the current one finishes.

The decoder thread may start decoding and buffering it, while the "current" song is still playing.

This variable is only valid if playing is true.

Definition at line 89 of file Playlist.hxx.

## ◆ stop_on_error

bool playlist::stop_on_error

If true, then any error is fatal; if false, MPD will attempt to play the next song on non-fatal errors.

During seeking, this flag is set.

Definition at line 53 of file Playlist.hxx.

The documentation for this struct was generated from the following file:

- queue/Playlist.hxx