summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a19118b)
raw | patch | inline | side by side (parent: a19118b)
author | Romain Bignon <romain@peerfuse.org> | |
Fri, 13 Feb 2009 09:56:35 +0000 (10:56 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 13 Feb 2009 09:59:17 +0000 (10:59 +0100) |
diff --git a/src/libmpdclient.c b/src/libmpdclient.c
index c037caeace2c3c2aec59fe18509f7ae686101939..ae362a1342ec1a2819cd84d14854dff8b64ac2e4 100644 (file)
--- a/src/libmpdclient.c
+++ b/src/libmpdclient.c
mpd_executeCommand(connection,"shuffle\n");
}
+void mpd_sendShuffleRangeCommand(mpd_Connection * connection, int start, int end) {
+ char * string = malloc(strlen("shufflerange")+25);
+ sprintf(string,"shuffle \"%i:%i\"\n", start, end);
+ mpd_executeCommand(connection,string);
+ free(string);
+}
+
void mpd_sendClearCommand(mpd_Connection * connection) {
mpd_executeCommand(connection,"clear\n");
}
diff --git a/src/libmpdclient.h b/src/libmpdclient.h
index cfa87a7d0803a3d99a41bb542d98a4f753a9f608..409a178ce81784246f8bbb16b6e2f18087282a5f 100644 (file)
--- a/src/libmpdclient.h
+++ b/src/libmpdclient.h
void mpd_sendShuffleCommand(mpd_Connection * connection);
+void mpd_sendShuffleRangeCommand(mpd_Connection * connection, int start, int end);
+
void mpd_sendClearCommand(mpd_Connection * connection);
/* use this to start playing at the beginning, useful when in random mode */
diff --git a/src/mpdclient.c b/src/mpdclient.c
index f5939e475e03e90cd020684978842b6a1865d1fc..809553030df861e066aaffa7f83e4a2044fb95cb 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
/* ncmpc (Ncurses MPD Client)
* (c) 2004-2009 The Music Player Daemon Project
* Project homepage: http://musicpd.org
-
+
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
return mpdclient_finish_command(c);
}
+gint
+mpdclient_cmd_shuffle_range(mpdclient_t *c, gint start, gint end)
+{
+ mpd_sendShuffleRangeCommand(c->connection, start, end);
+ c->need_update = TRUE;
+ return mpdclient_finish_command(c);
+}
+
gint
mpdclient_cmd_clear(mpdclient_t *c)
{
diff --git a/src/mpdclient.h b/src/mpdclient.h
index 1b52d06e9c739583f1ef11004bfeb935e8bc1e59..d4cabf3585993815446f368a6a135b88299651bd 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
gint mpdclient_cmd_prev(mpdclient_t *c);
gint mpdclient_cmd_seek(mpdclient_t *c, gint id, gint pos);
gint mpdclient_cmd_shuffle(mpdclient_t *c);
+gint mpdclient_cmd_shuffle_range(mpdclient_t *c, gint start, gint end);
gint mpdclient_cmd_clear(mpdclient_t *c);
gint mpdclient_cmd_repeat(mpdclient_t *c, gint value);
gint mpdclient_cmd_random(mpdclient_t *c, gint value);
diff --git a/src/screen_play.c b/src/screen_play.c
index 6984dfcac97678d44578637007910b6110653ea8..75b0f2edad5f03ce31912b66b40d2374b495ad43 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
return false;
case CMD_SHUFFLE:
{
- unsigned i = lw->selected_start + 1;
- unsigned last_selected = lw->selected;
if(!lw->visual_selection)
/* No visual selection, shuffle all list. */
break;
- for(; i <= lw->selected_end; ++i)
- mpdclient_cmd_move(c, i, lw->selected_start + (rand() % ((i - lw->selected_start) + 1)));
- lw->selected = last_selected;
- screen_status_printf(_("Shuffled selection!"));
+ if (mpdclient_cmd_shuffle_range(c, lw->selected_start, lw->selected_end+1) == 0)
+ screen_status_message(_("Shuffled playlist"));
return true;
}