Skip to content

Commit

Permalink
Support range argument for listplaylist and listplaylistinfo
Browse files Browse the repository at this point in the history
Adds two new functions:
- mpd_send_list_playlist_range
- mpd_send_list_playlist_range_meta
  • Loading branch information
jcorporation committed Feb 15, 2024
1 parent 714b5d6 commit 768a42e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
libmpdclient 2.23 (not yet released)
* support MPD protocol 0.24.0
- allow window for listplaylist and listplaylistinfo

libmpdclient 2.22 (2023/12/22)
* drop the unmaintained Vala bindings
Expand Down
32 changes: 32 additions & 0 deletions include/mpd/playlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ mpd_recv_playlist(struct mpd_connection *connection);
bool
mpd_send_list_playlist(struct mpd_connection *connection, const char *name);

/**
* Like mpd_send_list_playlist(), but specifies a (position) range.
* Use mpd_recv_entity() to receive the songs (#MPD_ENTITY_TYPE_SONG).
*
* @param connection the connection to MPD
* @param name the name of the playlist
* @param start the start position of the range (including)
* @param end the end position of the range (excluding); the special
* @return true on success, false on error
*
* @since libmpdclient 2.23, MPD 0.24
*/
bool
mpd_send_list_playlist_range(struct mpd_connection *connection, const char *name,
unsigned start, unsigned end);

/**
* List the content, with full metadata, of the stored playlist identified by
* name. Use mpd_recv_entity() to receive the songs (#MPD_ENTITY_TYPE_SONG).
Expand All @@ -151,6 +167,22 @@ mpd_send_list_playlist(struct mpd_connection *connection, const char *name);
bool
mpd_send_list_playlist_meta(struct mpd_connection *connection, const char *name);

/**
* Like mpd_send_list_playlist_meta(), but specifies a (position) range.
* Use mpd_recv_entity() to receive the songs (#MPD_ENTITY_TYPE_SONG).
*
* @param connection the connection to MPD
* @param name the name of the playlist
* @param start the start position of the range (including)
* @param end the end position of the range (excluding); the special
* @return true on success, false on error
*
* @since libmpdclient 2.23, MPD 0.24
*/
bool
mpd_send_list_playlist_range_meta(struct mpd_connection *connection, const char *name,
unsigned start, unsigned end);

/**
* Clear the playlist name (i.e. truncate name.m3u)
*
Expand Down
2 changes: 2 additions & 0 deletions libmpdclient.ld
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ global:
mpd_send_list_playlists;
mpd_recv_playlist;
mpd_send_list_playlist;
mpd_send_list_playlist_range;
mpd_send_list_playlist_meta;
mpd_send_list_playlist_range_meta;
mpd_send_playlist_clear;
mpd_run_playlist_clear;
mpd_send_playlist_add;
Expand Down
14 changes: 14 additions & 0 deletions src/cplaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,26 @@ mpd_send_list_playlist(struct mpd_connection *connection, const char *name)
return mpd_send_command(connection, "listplaylist", name, NULL);
}

bool
mpd_send_list_playlist_range(struct mpd_connection *connection, const char *name,
unsigned start, unsigned end)
{
return mpd_send_s_range_command(connection, "listplaylist", name, start, end);
}

bool
mpd_send_list_playlist_meta(struct mpd_connection *connection, const char *name)
{
return mpd_send_command(connection, "listplaylistinfo", name, NULL);
}

bool
mpd_send_list_playlist_range_meta(struct mpd_connection *connection, const char *name,
unsigned start, unsigned end)
{
return mpd_send_s_range_command(connection, "listplaylistinfo", name, start, end);
}

bool
mpd_send_playlist_clear(struct mpd_connection *connection, const char *name)
{
Expand Down

0 comments on commit 768a42e

Please sign in to comment.